I am using WordPress’s HTTP API which has a wrapper for cURL (I’ll assume it can do everything PHP’s cURL does).
Trying to check the following headers If-None-Match and If-Modified-Since via the API should return:
Status: 304 Not Modified
Instead I am getting a Status: 200 OK
Testing curl from the command line works fine and return the right status, this works:
curl -i https://api.github.com/users/wycks -H 'If-None-Match: "7efeb402e491989a4f37d8d82aae8946"'
Entering the same ETag in PHP 'If-None-Match' => '7efeb402e491989a4f37d8d82aae8946' doesn’t work.
Here is my PHP request to the API:
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
And the wrong response:
response' =>
array
'code' => int 200
'message' => string 'OK' (length=2)
I am not sure about underlying reasons but from some poking you need to quote etag value inside string: