HTTP GET changed to OPTIONS

46 views
Skip to first unread message

Seven Corners

unread,
May 17, 2010, 2:33:11 PM5/17/10
to Google Web Toolkit
I'm finding a strange situation where an HTTP GET gets changed to
OPTIONS, and I receive nothing from my GET. I'm working on an
application where I'll be working with various CRUD operations via
REST calls to my local server. Right now I'm just writing the GET and
finding that my response has no data and a status of 0. I learn from
the log that the GET has been changed to HTTP OPTIONS. Any clue why,
and what I can do to fix it? I think what I need to do is a common
and straightforward thing; surely other people have run into this?

This is my code:

public class RESTClient
{
public static void doGET(String strLoginName, String strLoginPassword,
String strURL, RequestCallback callback) throws RequestException
{
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
URL.encode(strURL));
// Authorization:auth-type="mii-basic",login-name="root",login-
password="root"
builder.setHeader("Authorization", auth-type=\"mii-basic\",login-
name=\"" + strLoginName +"\",login-password=\""+strLoginPassword +
"\"");
builder.setTimeoutMillis(2000);
builder.sendRequest(null, callback);
}
}

It's invoked from my main class thus:

private final String m_kstrJSONAcctURL = "http://127.0.0.1:8080/v1/
authsrvc/accounts/myAccount.json";
...

RESTClient.doGET("root", "root", m_kstrJSONAcctURL, new
RequestCallback()
{
public void onError(Request request, Throwable exception)
{
...
// We never get here
}

public void onResponseReceived(Request request, Response
response)
{
// Here we find our response
status is 0
}
});

So note that we're running with two different ports. The REST service
uses Jetty and is on port 8080, while my caller uses the debugger's
Apache and is on port 8888. Any ideas?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Thomas Broyer

unread,
May 18, 2010, 6:46:39 PM5/18/10
to Google Web Toolkit


On 17 mai, 20:33, Seven Corners <she...@shelahhorvitz.com> wrote:
> I'm finding a strange situation where an HTTP GET gets changed to
> OPTIONS, and I receive nothing from my GET.  I'm working on an
> application where I'll be working with various CRUD operations via
> REST calls to my local server.  Right now I'm just writing the GET and
> finding that my response has no data and a status of 0.  I learn from
> the log that the GET has been changed to HTTP OPTIONS.  Any clue why,
> and what I can do to fix it?

http://www.w3.org/TR/cors/#cross-origin-request-with-preflight0

> I think what I need to do is a common
> and straightforward thing; surely other people have run into this?

With most browsers until last year, it would have failed, because of
the "same origin policy". Nowadays, all "modern" browsers (with the
notable exception of IE) implement CORS, but older versions still
don't. (t should be noted that IE8 supports CORS but you have to use a
special XDomainRequest instead of XMLHttpRequest, and GWT isn't
designed with cross-origin requests in view so it won't use
XDomainRequest)
Reply all
Reply to author
Forward
0 new messages