GWT RPC 响应标头

发布于 2024-10-01 00:04:38 字数 820 浏览 5 评论 0原文

有没有办法读取 GWT 客户端在 RPC 响应上收到的标头信息?

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>

参数 Response 上存在的方法

public void onResponseReceived(Request request, Response response) { ... }

似乎有我需要的信息。这是,是否有某种方法可以在不“破坏”GWT 编译器代码的情况下实现这一点?

谢谢

朱达克

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜心 2024-10-08 00:04:38

您可以尝试重写 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/

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/

递刀给你 2024-10-08 00:04:38

如果您声明异步服务方法返回 RequestBuilder 您应该能够设置 RequestCallback,当 响应已收到。我自己没有尝试过,但它看起来像你所需要的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文