Monday, September 13, 2010

Re: How to get HTTP Response headers?

On Sep 13, 3:10 am, ussuri <michael.glas...@gmail.com> wrote:
> I am getting an exception inside GWT:
>
> code:
>
> @Override
> public void onResponseReceived( Request request,
>                         Response response)
>  {
>         String toPop = "";
>         Header[] headers = response.getHeaders();
>         ....
>
> Exception:
>
> 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.***$2.onResponseReceived(***.java:153)
>
> GWT version is 2.0.4
>
> What is interesting, is that although I am calling
> response.getHeaders(), the stack trace shows that Request.getHeaders()
> is called.

The stack-trace, shows that the Response object you've been passed is
an anonymous inner-class of Request (Request$1), whose getHeaders
method delegate to a method on the Request class (have a look at the
code the details)

> The exception is there in the compiled code as well. What
> can be the cause? A broken GWT installation?

Have you checked the status code? It appears (from the line number
given in the stack trace) that the XMLHttpRequest's
getAllResponseHeaders returned 'null', so I suspect some kind of error
(that wouldn't be flagged as an error by GWT, so there may be a bug
here; but maybe there's some kind of "bug" in your code too)
Can't you inspect the request in some devtool such as Firebug?

--
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment