Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(extension/fetch): Fetching with method HEAD should not have body #11003

Merged
merged 7 commits into from Jun 18, 2021

Conversation

getspooky
Copy link
Contributor

HEAD and OPTIONS requests should not have bodies https://fetch.spec.whatwg.org/#concept-main-fetch

@getspooky
Copy link
Contributor Author

Current behaviour

const response = await fetch("https://api.github.com/users/denoland", {
  method: "HEAD",
});
// Result 
/*
Response {
  body: null,
  bodyUsed: false,
  headers: Headers {
  "accept-ranges": "bytes",
  "access-control-allow-origin": "*",
  "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLim...",
  "cache-control": "public, max-age=60, s-maxage=60",
  "content-security-policy": "default-src 'none'",
  "content-type": "application/json; charset=utf-8",
  date: "Wed, 16 Jun 2021 11:35:08 GMT",
  etag: 'W/"456078ee283e268960ebf9ee2fbdd5f8f40cd215f8811a5b0917b05b49fefcd1"',
  "last-modified": "Wed, 31 Mar 2021 14:25:32 GMT",
  "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
  server: "GitHub.com",
  "strict-transport-security": "max-age=31536000; includeSubdomains; preload",
  vary: "Accept, Accept-Encoding, Accept, X-Requested-With",
  "x-content-type-options": "nosniff",
  "x-frame-options": "deny",
  "x-github-media-type": "github.v3; format=json",
  "x-github-request-id": "8924:60BE:202550:24EC32:60C9E1EC",
  "x-ratelimit-limit": "60",
  "x-ratelimit-remaining": "57",
  "x-ratelimit-reset": "1623846694",
  "x-ratelimit-resource": "core",
  "x-ratelimit-used": "3",
  "x-xss-protection": "0"
},
  ok: true,
  redirected: false,
  status: 200,
  statusText: "OK",
  url: "https://api.github.com/users/denoland"
}
*/

extensions/fetch/26_fetch.js Show resolved Hide resolved
test.ts Outdated Show resolved Hide resolved
getspooky and others added 2 commits June 17, 2021 22:06
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants