diff options
author | Luca Casonato <hello@lcas.dev> | 2021-10-11 18:39:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-11 18:39:55 +0200 |
commit | c40d5040cd577aa4ebe552242a06163fbcbc3d4b (patch) | |
tree | a3161729708e68d6de9a5b73e4f0d78ae7a8b536 /ext/http/01_http.js | |
parent | 70978fd05a2ef8b5035a2e829c21cdc13c05ac5b (diff) |
fix(http): don't expose body on GET/HEAD requests (#12260)
GET/HEAD requests can't have bodies according to `fetch` spec. This
commit changes the HTTP server to hide request bodies for requests with
GET or HEAD methods.
Diffstat (limited to 'ext/http/01_http.js')
-rw-r--r-- | ext/http/01_http.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/http/01_http.js b/ext/http/01_http.js index 8c4f08aab..4e6b8fc00 100644 --- a/ext/http/01_http.js +++ b/ext/http/01_http.js @@ -93,7 +93,12 @@ let body = null; if (typeof requestRid === "number") { SetPrototypeAdd(this.managedResources, requestRid); - body = createRequestBodyStream(this, requestRid); + // There might be a body, but we don't expose it for GET/HEAD requests. + // It will be closed automatically once the request has been handled and + // the response has been sent. + if (method !== "GET" && method !== "HEAD") { + body = createRequestBodyStream(this, requestRid); + } } const innerRequest = newInnerRequest( |