Hi Andrei :) Since nobody answered, I hope the following pointers helps you in debugging.
A similar thread with a reply from Thomas is here https://groups.google.com/group/google-web-toolkit/browse_thread/thread/4f4132bc90f6375a In GWT source, have a look at * ./user/src/com/google/gwt/http/client/Response.java * ./user/src/com/google/gwt/http/client/Request.java String allHeaders = xmlHttp.getAllResponseHeaders(); [line 88] String[] unparsedHeaders = allHeaders.split("\n"); * ./user/src/com/google/gwt/xhr/client/XMLHttpRequest.java public final native String getAllResponseHeaders() /*-{ return this.getAllResponseHeaders(); }-*/; See also http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders-method What does getReadyState() return? (don't know how exactly would this be called from a Request class). Looks like it works only if(this.readyState == 2) M On Dec 16, 5:03 pm, Andrei Gheorghe <[email protected]> wrote: > Hi there > > I am trying to make a REST call through HTTPS and read the response > headers. Even though the response text (response.getText()) has > absolutely no problem, getHeaders() throws a NullPointerException: > > java.lang.NullPointerException: null > at com.google.gwt.http.client.Request.getHeaders(Request.java:88) > at com.google.gwt.http.client.Request.access$0(Request.java:86) > at com.google.gwt.http.client.Request$1.getHeaders(Request.java: > 53) > at com.bc.adminconsole.client.shared.core.services.ServiceBase > $1.onResponseReceived(ServiceBase.java:76) > at > com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java: > 287) > at com.google.gwt.http.client.RequestBuilder > $1.onReadyStateChange(RequestBuilder.java:395) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > 39) > > My code is mostly like this (RestService creates a RequestBuilder when > calling ()). > > RestService restService = new RestService(requestUri, requestMethod, > requestBody, authToken); > > RequestCallback r = new RequestCallback() { > @Override > public void onResponseReceived(Request request, Response response) { > int responseStatusCode = response.getStatusCode(); > if (responseStatusCode != Response.SC_OK && > responseStatusCode != > Response.SC_CREATED) { > // ... stuff ... > } else { > headers = response.getHeaders(); > T result = reader.read(response.getText()); > > resultCallback.onSuccess(result); > } > } > > // ... stuff ... > > }; > > restService.setCallback(r); > restService.send(); > > Any ideas why getHeaders() would return null even though my request > has statusCode 201 and everything else is OK? > > Thank you! -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
