diff options
author | 2023-03-01 23:28:21 -0600 | |
---|---|---|
committer | 2023-03-01 21:28:21 -0800 | |
commit | b9137dbdc81591f8b30cf95a4d27514bfb1ae71c (patch) | |
tree | c369d655111fbc3d1d346dbfc22f3d2f699a33e9 /src | |
parent | 706a3e8169ae27b1b5c3694d46b593f220c41b80 (diff) | |
download | bun-b9137dbdc81591f8b30cf95a4d27514bfb1ae71c.tar.gz bun-b9137dbdc81591f8b30cf95a4d27514bfb1ae71c.tar.zst bun-b9137dbdc81591f8b30cf95a4d27514bfb1ae71c.zip |
fix(node:http): match Node `http.request()` GET/HEAD w/ body (#2262)
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/http.exports.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/bun.js/http.exports.js b/src/bun.js/http.exports.js index a7f67f0e9..d21f768d4 100644 --- a/src/bun.js/http.exports.js +++ b/src/bun.js/http.exports.js @@ -959,10 +959,14 @@ export class ClientRequest extends OutgoingMessage { if (this.#signal?.aborted) { this[kAbortController].abort(); } + + var method = this.#method, + body = this.#body; + this.#fetchRequest = fetch(`${this.#protocol}//${this.#host}:${this.#port}${this.#path}`, { - method: this.#method, + method, headers: this.getHeaders(), - body: this.#body || undefined, + body: body && method !== "GET" && method !== "HEAD" && method !== "OPTIONS" ? body : undefined, redirect: "manual", verbose: Boolean(__DEBUG__), signal: this[kAbortController].signal, |