Mirror: A Node.js fetch shim using built-in Request, Response, and Headers (but without native fetch)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: Add `Content-Length: 0` for empty `PATCH` bodies (#23)

authored by

Phil Pluckthun and committed by
GitHub
93d78107 4c068d1d

+9 -1
+5
.changeset/every-coats-decide.md
··· 1 + --- 2 + 'fetch-nodeshim': patch 3 + --- 4 + 5 + Set `Content-Length: 0` when `response.body` is `null` for `PATCH` as well
+4 -1
src/fetch.ts
··· 253 253 if (requestBody.contentType) 254 254 requestHeaders.set('Content-Type', requestBody.contentType); 255 255 256 - if (requestBody.body == null && (method === 'POST' || method === 'PUT')) { 256 + if ( 257 + requestBody.body == null && 258 + (method === 'POST' || method === 'PUT' || method === 'PATCH') 259 + ) { 257 260 requestHeaders.set('Content-Length', '0'); 258 261 } else if (requestBody.body != null && requestBody.contentLength != null) { 259 262 requestHeaders.set('Content-Length', `${requestBody.contentLength}`);