Reputation: 85
Is there any way to read the header information received by GWT client, on the RPC response?
Response header
Server Apache-Coyote/1.1
Set-Cookie JSESSIONID=3379B1E57BEB2FE227EDC1F57BF550ED; Path=/GWT
Content-Encoding gzip
Content-Disposition attachment
Content-Type application/json;charset=utf-8
Content-Length 209
Date Fri, 05 Nov 2010 13:07:31 GMT
I'm particularly interest in identifying when client receives the Set-Cookie attribute on its header.
Is there any way to do that on GWT?
I found that on
com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter<T>
exist the method
public void onResponseReceived(Request request, Response response) { ... }
On the parameter Response seems to have the information I need. The this is, exist some way to get that without "racking" the GWT compiler code?
thanks
JuDaC
Upvotes: 5
Views: 3621
Reputation: 11
You may try to override the RpcRequestBuilder.doSetCallback
method and force your service to use it:
MyServiceAsync service = GWT.create(MyService.clas);
((ServiceDefTarget) service).setRpcRequestBuilder(new RpcRequestBuilder() {
@Override
protected void doSetCallback(RequestBuilder rb, final RequestCallback callback) {
super.doSetCallback(rb, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
String headerValue = response.getHeader("my-header");
// do sth...
callback.onResponseReceived(request, response);
}
@Override
public void onError(Request request, Throwable exception) {
callback.onError(request, exception);
}
});
}
});
Inspired by http://stuffthathappens.com/blog/2009/12/22/custom-http-headers-with-gwt-rpc/
Upvotes: 1
Reputation: 8874
If you declare your async service method to return a RequestBuilder you should be able to set a RequestCallback that will be notified when the Response is received. I haven't tried this myself, but it looks like what you need.
Upvotes: 0