我使用WordPress的HTTP API,它有一个cURL包装器(我假设它可以做PHP的cURL所做的一切)。
尝试通过API检查以下标头If-None-Match
和If-Modified-Since
应该返回:
Status: 304 Not Modified
相反,我得到一个Status: 200 OK
从命令行测试curl可以正常工作,并返回正确的状态,这行得通:
curl -i https://api.github.com/users/wycks -H 'If-None-Match: "7efeb402e491989a4f37d8d82aae8946"'
在PHP 'If-None-Match' => '7efeb402e491989a4f37d8d82aae8946'
中输入相同的ETag不工作。
array
'method' => string 'HEAD' (length=4)
'timeout' => int 5
'redirection' => int 0
'httpversion' => string '1.0' (length=3)
'user-agent' => string 'WordPress/3.5; http://dev.local/Foo15' (length=37)
'blocking' => boolean true
'headers' =>
array
'Accept-Encoding' => string 'deflate;q=1.0, compress;q=0.5' (length=29)
'cookies' =>
array
empty
'body' => null
'compress' => boolean false
'decompress' => boolean true
'sslverify' => boolean false
'stream' => boolean false
'filename' => null
'If-None-Match' => string '7efeb402e491989a4f37d8d82aae8946' (length=32)
'Cache-Control' => string 'must-revalidate' (length=15)
'_redirection' => int 0
'ssl' => boolean true
'local' => boolean false
boolean true
和错误的响应:
response' =>
array
'code' => int 200
'message' => string 'OK' (length=2)
我不确定潜在的原因,但从一些戳你需要引用etag值内字符串:
'If-None-Match' => '"7efeb402e491989a4f37d8d82aae8946"'