gpt4 book ai didi

java - 为什么 Http Get 不返回 If-None-Match?

转载 作者:可可西里 更新时间:2023-11-01 16:21:30 27 4
gpt4 key购买 nike

我使用 curl 测试,它返回 304 Not Modified

curl -i -H "If-None-Match: \"df3c2a09938aa3c0cfdb945a41a5c2430e3832b6\"" "https://graph.facebook.com/v2.4/me/adaccounts?access_token=******************************"

这是来自服务器的响应:

 HTTP/1.1 304 Not Modified
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=UTF-8
X-FB-Trace-ID: Ef0W7CPfAwo
X-FB-Rev: 1907442
Pragma: no-cache
Cache-Control: private, no-cache, no-store, must-revalidate
Facebook-API-Version: v2.4
Expires: Sat, 01 Jan 2000 00:00:00 GMT
X-FB-Debug: tGY11aw+eMAejPHXFtD4REFwgwzFR6GLrVvwl6f5aeZsVVwq+AGSa2i5TOfk8C7523h+
0S6M3TOTOK94ABIZ4w==
Date: Fri, 28 Aug 2015 03:07:59 GMT
Connection: keep-alive
Content-Length: 0

但是在 java 中我使用下面的代码但是它没有返回 304 Not Modified

    URL sourceURL = new URL("https://graph.facebook.com/v2.4/me/adaccounts?access_token=************************");
HttpURLConnection sourceConnection = (HttpURLConnection) sourceURL.openConnection();
sourceConnection.addRequestProperty("If-None-Match", "df3c2a09938aa3c0cfdb945a41a5c2430e3832b6");
sourceConnection.connect();

这是来自服务器的响应:

null:HTTP/1.1 200 OK
ETag:"df3c2a09938aa3c0cfdb945a41a5c2430e3832b6"
Content-Length:342
Expires:Sat, 01 Jan 2000 00:00:00 GMT
Connection:keep-alive
Cache-Control:private, no-cache, no-store, must-revalidate
Pragma:no-cache
X-FB-Debug:BDqNs5aELmixSyTcDnmFGio4veU494IJh7/mlAxzfVX705e2cmNwtswGYp38XOyfL6gAOS1ZyvAWdl25k0Nx/g==
Access-Control-Allow-Origin:*
Date:Fri, 28 Aug 2015 03:08:49 GMT
Facebook-API-Version:v2.4
X-FB-Trace-ID:C9BsIg/gIFq
Content-Type:application/json; charset=UTF-8
X-FB-Rev:1907442

有人能告诉我原因吗?非常感谢。

最佳答案

需要引用实体标签:)

response 
ETag: "df3c2a09938aa3c0cfdb945a41a5c2430e3832b6"

request
If-None-Match: "df3c2a09938aa3c0cfdb945a41a5c2430e3832b6"

你设置的请求头没有被引用:)

关于java - 为什么 Http Get 不返回 If-None-Match?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32262877/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com