有没有办法在RPC响应中读取GWT客户端收到的头信息? Response headerServer Apache-Coyote/1.1Set-Cookie JSESSIONID=3379B1E57BEB2FE227EDC1F57BF550ED; Path=/GWTContent-Encoding gzipContent-Disposition attachmentContent-Type ap
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
我特别感兴趣的是确定客户端何时在其标头上收到Set-Cookie属性.
有没有办法在GWT上做到这一点?
我发现了
com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter<T>
存在方法
public void onResponseReceived(Request request, Response response) { ... }
在参数Response似乎有我需要的信息.这是存在某种方式来获得,而不“绞乱”GWT编译器代码?
谢谢
JuDaC
您可以尝试覆盖RpcRequestBuilder.doSetCallback方法并强制您的服务使用它: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); } }); } });
受到http://stuffthathappens.com/blog/2009/12/22/custom-http-headers-with-gwt-rpc/的启发