-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I have not been able to achieve expected operation when passing the If-None-Match header to gh api.
I've been following this api guide.
>>gh --version
gh version 1.5.0 (2021-01-21)
https://github.com/cli/cli/releases/tag/v1.5.0
Steps to reproduce the behavior
gh api -i https://api.github.com/users/benplay2
HTTP/2.0 200 OK
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
Cache-Control: private, max-age=60, s-maxage=60
Content-Security-Policy: default-src 'none'
Content-Type: application/json; charset=utf-8
Date: Wed, 10 Feb 2021 00:47:30 GMT
Etag: W/"90552ff69ccdd8a38d5d86b0071b28b8f4310c17c4dc576806dfcf3140d20787"
Last-Modified: Thu, 04 Feb 2021 12:33:56 GMT
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Server: GitHub.com
...
- Copy the etag returned in the header, and use it in the next call
gh api -i https://api.github.com/users/benplay2 -H If-None-Match:"90552ff69ccdd8a38d5d86b0071b28b8f4310c17c4dc576806dfcf3140d20787"
HTTP/2.0 200 OK
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
Cache-Control: private, max-age=60, s-maxage=60
Content-Security-Policy: default-src 'none'
Content-Type: application/json; charset=utf-8
Date: Wed, 10 Feb 2021 00:51:04 GMT
Etag: W/"90552ff69ccdd8a38d5d86b0071b28b8f4310c17c4dc576806dfcf3140d20787"
Last-Modified: Thu, 04 Feb 2021 12:33:56 GMT
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Server: GitHub.com
...
Expected vs actual behavior
I expect to receive HTTP code 304 when the returned ETag matches the code specified in the request, but instead I always receive 200 OK.
When I try the same command with curl, it behaves as expected:
curl -i https://api.github.com/users/benplay2
curl -i https://api.github.com/users/benplay2
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1295 100 1295 0 0 5655 0 --:--:-- --:--:-- --:--:-- 5630HTTP/2 200
server: GitHub.com
date: Wed, 10 Feb 2021 00:53:57 GMT
content-type: application/json; charset=utf-8
cache-control: public, max-age=60, s-maxage=60
vary: Accept, Accept-Encoding, Accept, X-Requested-With
etag: W/"fafba5701f93adc7d2108fc3ee8021fd511a046a5cd9ba7649de48cfafd2a83e"
last-modified: Thu, 04 Feb 2021 12:33:56 GMT
x-github-media-type: github.v3; format=json
...
curl -i -H 'If-None-Match: "fafba5701f93adc7d2108fc3ee8021fd511a046a5cd9ba7649de48cfafd2a83e"' https://api.github.com/users/benplay2
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HTTP/2 304
server: GitHub.com
date: Wed, 10 Feb 2021 00:55:17 GMT
content-type: application/json; charset=utf-8
cache-control: public, max-age=60, s-maxage=60
vary: Accept, Accept-Encoding, Accept, X-Requested-With
etag: W/"fafba5701f93adc7d2108fc3ee8021fd511a046a5cd9ba7649de48cfafd2a83e"
last-modified: Thu, 04 Feb 2021 12:33:56 GMT
x-github-media-type: github.v3; format=json
...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working