weixin_33737134 2012-04-19 08:25 采纳率: 0%
浏览 25

响应中从200代替304

Simple problem:

onResponseReceive getStatusCode returns 200 instead of 304. Fiddler tells me that the Response statuscode is 304.

What do I do: I constantly poll the server for new data (every 10 seconds). If the data hasn't changed, it responses with 304, else with 200 and the whole data. In the onResponseReceived method, the statuscode is always 200, and the data is always present.

Any tipps how to get the 304. I read something about If-Modified-Since, which would causes a whole resend of the data (with code 200) but I actually want the 304. I also don't want to comapre the data by hand, to see if it changed.

GWT Code:

RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET,
                dataUrl);

        requestBuilder.setHeader("_____", "none");
        requestBuilder.setHeader("_______", "_________");
        requestBuilder.setCallback(new RequestCallback() {

            @Override
            public void onResponseReceived(Request request, Response response) {
                PrintResponse.printResponse(response, "EntryPoints");
            if (response.getStatusCode() == 200) {.....}  

            }

            @Override
            public void onError(Request request, Throwable exception) {

            }
        });

        try {
            requestBuilder.send();
        } catch (RequestException e) {
            e.printStackTrace();
        }

Response:

HTTP/1.1 304
Content-Type: application/json
Cache-Control: max-age=0
Content-Length: 0
Date: Thu, 19 Apr 2012 10:49:10 GMT
Server: ________
Connection: Keep-Alive
Keep-Alive: timeout=60

Best Regards, Stefan

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!