2015-08-28 78 views
3

我使用捲曲測試並返回304未修改爲什麼Http Get不返回If-None-Match?

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未修改

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 

有人可以告訴我理由嗎? 非常感謝。

回答

1

實體標籤需要被引用:)

response 
    ETag: "df3c2a09938aa3c0cfdb945a41a5c2430e3832b6" 

request 
    If-None-Match: "df3c2a09938aa3c0cfdb945a41a5c2430e3832b6" 

您設置的請求頭沒有加引號:)