Comparing version 12.0.3 to 12.0.4
@@ -124,4 +124,2 @@ /// <reference types="node" /> | ||
unpipe<T extends NodeJS.WritableStream>(destination: T): this; | ||
private _lockWrite; | ||
private _unlockWrite; | ||
private _finalizeBody; | ||
@@ -128,0 +126,0 @@ private _onResponseBase; |
@@ -204,20 +204,2 @@ import process from 'node:process'; | ||
this._stopRetry = noop; | ||
const unlockWrite = () => { | ||
this._unlockWrite(); | ||
}; | ||
const lockWrite = () => { | ||
this._lockWrite(); | ||
}; | ||
this.on('pipe', (source) => { | ||
source.prependListener('data', unlockWrite); | ||
source.on('data', lockWrite); | ||
source.prependListener('end', unlockWrite); | ||
source.on('end', lockWrite); | ||
}); | ||
this.on('unpipe', (source) => { | ||
source.off('data', unlockWrite); | ||
source.off('data', lockWrite); | ||
source.off('end', unlockWrite); | ||
source.off('end', lockWrite); | ||
}); | ||
this.on('pipe', source => { | ||
@@ -254,8 +236,5 @@ if (source.headers) { | ||
} | ||
const { json, body, form } = this.options; | ||
if (json || body || form) { | ||
this._lockWrite(); | ||
} | ||
// Important! If you replace `body` in a handler with another stream, make sure it's readable first. | ||
// The below is run only once. | ||
const { body } = this.options; | ||
if (is.nodeStream(body)) { | ||
@@ -497,13 +476,2 @@ body.once('error', error => { | ||
} | ||
_lockWrite() { | ||
const onLockedWrite = () => { | ||
throw new TypeError('The payload has been already provided'); | ||
}; | ||
this.write = onLockedWrite; | ||
this.end = onLockedWrite; | ||
} | ||
_unlockWrite() { | ||
this.write = super.write; | ||
this.end = super.end; | ||
} | ||
async _finalizeBody() { | ||
@@ -569,8 +537,2 @@ const { options } = this; | ||
} | ||
else if (cannotHaveBody) { | ||
this._lockWrite(); | ||
} | ||
else { | ||
this._unlockWrite(); | ||
} | ||
if (options.responseType === 'json' && !('accept' in options.headers)) { | ||
@@ -836,14 +798,9 @@ options.headers.accept = 'application/json'; | ||
} | ||
else { | ||
this._unlockWrite(); | ||
if (!is.undefined(body)) { | ||
this._writeRequest(body, undefined, () => { }); | ||
currentRequest.end(); | ||
this._lockWrite(); | ||
} | ||
else if (this._cannotHaveBody || this._noPipe) { | ||
currentRequest.end(); | ||
this._lockWrite(); | ||
} | ||
else if (!is.undefined(body)) { | ||
this._writeRequest(body, undefined, () => { }); | ||
currentRequest.end(); | ||
} | ||
else if (this._cannotHaveBody || this._noPipe) { | ||
currentRequest.end(); | ||
} | ||
} | ||
@@ -850,0 +807,0 @@ _prepareCache(cache) { |
{ | ||
"name": "got", | ||
"version": "12.0.3", | ||
"version": "12.0.4", | ||
"description": "Human-friendly and powerful HTTP request library for Node.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
243179
5341