@whatwg-node/node-fetch
Advanced tools
Comparing version 0.5.20 to 0.5.21-alpha-20240805010752-0091eb73bd34a7b9e242a22352afacb8ac728cb7
@@ -52,2 +52,26 @@ "use strict"; | ||
} | ||
handleContentLengthHeader(forceSet = false) { | ||
const contentTypeInHeaders = this.headers.get('content-type'); | ||
if (!contentTypeInHeaders) { | ||
if (this.contentType) { | ||
this.headers.set('content-type', this.contentType); | ||
} | ||
} | ||
else { | ||
this.contentType = contentTypeInHeaders; | ||
} | ||
const contentLengthInHeaders = this.headers.get('content-length'); | ||
if (forceSet && this.bodyInit == null && !contentLengthInHeaders) { | ||
this.contentLength = 0; | ||
this.headers.set('content-length', '0'); | ||
} | ||
if (!contentLengthInHeaders) { | ||
if (this.contentLength) { | ||
this.headers.set('content-length', this.contentLength.toString()); | ||
} | ||
} | ||
else { | ||
this.contentLength = parseInt(contentLengthInHeaders, 10); | ||
} | ||
} | ||
get body() { | ||
@@ -54,0 +78,0 @@ const _body = this.generateBody(); |
@@ -55,24 +55,3 @@ "use strict"; | ||
if (this.method !== 'GET' && this.method !== 'HEAD') { | ||
const contentTypeInHeaders = this.headers.get('content-type'); | ||
if (!contentTypeInHeaders) { | ||
if (this.contentType) { | ||
this.headers.set('content-type', this.contentType); | ||
} | ||
} | ||
else { | ||
this.contentType = contentTypeInHeaders; | ||
} | ||
const contentLengthInHeaders = this.headers.get('content-length'); | ||
if (bodyInit == null && !contentLengthInHeaders) { | ||
this.contentLength = 0; | ||
this.headers.set('content-length', '0'); | ||
} | ||
if (!contentLengthInHeaders) { | ||
if (this.contentLength) { | ||
this.headers.set('content-length', this.contentLength.toString()); | ||
} | ||
} | ||
else { | ||
this.contentLength = parseInt(contentLengthInHeaders, 10); | ||
} | ||
this.handleContentLengthHeader(true); | ||
} | ||
@@ -79,0 +58,0 @@ if (requestInit?.agent != null) { |
@@ -21,20 +21,3 @@ "use strict"; | ||
this.type = init?.type || 'default'; | ||
const contentTypeInHeaders = this.headers.get('content-type'); | ||
if (!contentTypeInHeaders) { | ||
if (this.contentType) { | ||
this.headers.set('content-type', this.contentType); | ||
} | ||
} | ||
else { | ||
this.contentType = contentTypeInHeaders; | ||
} | ||
const contentLengthInHeaders = this.headers.get('content-length'); | ||
if (!contentLengthInHeaders) { | ||
if (this.contentLength) { | ||
this.headers.set('content-length', this.contentLength.toString()); | ||
} | ||
} | ||
else { | ||
this.contentLength = parseInt(contentLengthInHeaders, 10); | ||
} | ||
this.handleContentLengthHeader(); | ||
} | ||
@@ -41,0 +24,0 @@ get ok() { |
@@ -48,2 +48,26 @@ import { Readable } from 'stream'; | ||
} | ||
handleContentLengthHeader(forceSet = false) { | ||
const contentTypeInHeaders = this.headers.get('content-type'); | ||
if (!contentTypeInHeaders) { | ||
if (this.contentType) { | ||
this.headers.set('content-type', this.contentType); | ||
} | ||
} | ||
else { | ||
this.contentType = contentTypeInHeaders; | ||
} | ||
const contentLengthInHeaders = this.headers.get('content-length'); | ||
if (forceSet && this.bodyInit == null && !contentLengthInHeaders) { | ||
this.contentLength = 0; | ||
this.headers.set('content-length', '0'); | ||
} | ||
if (!contentLengthInHeaders) { | ||
if (this.contentLength) { | ||
this.headers.set('content-length', this.contentLength.toString()); | ||
} | ||
} | ||
else { | ||
this.contentLength = parseInt(contentLengthInHeaders, 10); | ||
} | ||
} | ||
get body() { | ||
@@ -50,0 +74,0 @@ const _body = this.generateBody(); |
@@ -52,24 +52,3 @@ import { Agent as HTTPAgent, globalAgent as httpGlobalAgent } from 'http'; | ||
if (this.method !== 'GET' && this.method !== 'HEAD') { | ||
const contentTypeInHeaders = this.headers.get('content-type'); | ||
if (!contentTypeInHeaders) { | ||
if (this.contentType) { | ||
this.headers.set('content-type', this.contentType); | ||
} | ||
} | ||
else { | ||
this.contentType = contentTypeInHeaders; | ||
} | ||
const contentLengthInHeaders = this.headers.get('content-length'); | ||
if (bodyInit == null && !contentLengthInHeaders) { | ||
this.contentLength = 0; | ||
this.headers.set('content-length', '0'); | ||
} | ||
if (!contentLengthInHeaders) { | ||
if (this.contentLength) { | ||
this.headers.set('content-length', this.contentLength.toString()); | ||
} | ||
} | ||
else { | ||
this.contentLength = parseInt(contentLengthInHeaders, 10); | ||
} | ||
this.handleContentLengthHeader(true); | ||
} | ||
@@ -76,0 +55,0 @@ if (requestInit?.agent != null) { |
@@ -18,20 +18,3 @@ import { STATUS_CODES } from 'http'; | ||
this.type = init?.type || 'default'; | ||
const contentTypeInHeaders = this.headers.get('content-type'); | ||
if (!contentTypeInHeaders) { | ||
if (this.contentType) { | ||
this.headers.set('content-type', this.contentType); | ||
} | ||
} | ||
else { | ||
this.contentType = contentTypeInHeaders; | ||
} | ||
const contentLengthInHeaders = this.headers.get('content-length'); | ||
if (!contentLengthInHeaders) { | ||
if (this.contentLength) { | ||
this.headers.set('content-length', this.contentLength.toString()); | ||
} | ||
} | ||
else { | ||
this.contentLength = parseInt(contentLengthInHeaders, 10); | ||
} | ||
this.handleContentLengthHeader(); | ||
} | ||
@@ -38,0 +21,0 @@ get ok() { |
{ | ||
"name": "@whatwg-node/node-fetch", | ||
"version": "0.5.20", | ||
"version": "0.5.21-alpha-20240805010752-0091eb73bd34a7b9e242a22352afacb8ac728cb7", | ||
"description": "Fetch API implementation for Node", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -30,2 +30,5 @@ import { Readable } from 'stream'; | ||
private generateBody; | ||
protected handleContentLengthHeader(this: PonyfillBody & { | ||
headers: Headers; | ||
}, forceSet?: boolean): void; | ||
get body(): PonyfillReadableStream<Uint8Array> | null; | ||
@@ -32,0 +35,0 @@ _chunks: Uint8Array[] | null; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
198218
5118