gwt.http.client.request always returns status==0 and null headers.

118 views
Skip to first unread message

chetr

unread,
Jan 13, 2011, 7:14:12 PM1/13/11
to Google Web Toolkit
I have worked with GWT quite a bit, including rpc, however I have been
unable to get a simple com.google.gwt.http.client.Request working. I
have included the module into mine and am using the example code. The
callback onResponseReceived() always receives a response object with
the status code == 0. response.getHeadersAsString() gives a null
exception. I have played with different WOKRING urls and I always get
the same results. I have the same results with gwt 2.0.3 and 2.1.1

thanks, Chet

String url = "http://localhost/index.html";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
URL.encode(url));
try {
Request request = builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
displaySearchResults( "ERROR" );
}
public void onResponseReceived(Request request,
com.google.gwt.http.client.Response response) {
if (200 == response.getStatusCode()) {
displaySearchResults( response.getText() );
} else {
displaySearchResults( "WRONG STATUS CODE" );
}
}
});
} catch (RequestException e) {
displaySearchResults( "CONNECT ERROR" );
}
}

Thomas Broyer

unread,
Jan 14, 2011, 9:05:06 AM1/14/11
to google-we...@googlegroups.com
You're hitting the "Same Origin Policy" (search for this on WikiPedia and on the group archives).
Reply all
Reply to author
Forward
0 new messages