Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT RPC response header

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

like image 955
JuDaC Avatar asked Nov 14 '22 06:11

JuDaC


1 Answers

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/

like image 146
Daniel M. Avatar answered Dec 04 '22 03:12

Daniel M.