Comparing version 11.1.2 to 11.1.3
@@ -32,2 +32,3 @@ /// <reference types="node" /> | ||
declare const kJobs: unique symbol; | ||
declare const kOriginalResponse: unique symbol; | ||
export declare const kIsNormalizedAlready: unique symbol; | ||
@@ -253,2 +254,3 @@ export interface Agents { | ||
[kResponse]?: IncomingMessage; | ||
[kOriginalResponse]?: IncomingMessage; | ||
[kRequest]?: ClientRequest; | ||
@@ -255,0 +257,0 @@ _noPipe?: boolean; |
@@ -41,2 +41,3 @@ "use strict"; | ||
const kJobs = Symbol('jobs'); | ||
const kOriginalResponse = Symbol('originalResponse'); | ||
exports.kIsNormalizedAlready = Symbol('isNormalizedAlready'); | ||
@@ -197,3 +198,2 @@ const supportsBrotli = is_1.default.string(process.versions.brotli); | ||
'socket', | ||
'abort', | ||
'connect', | ||
@@ -269,3 +269,3 @@ 'continue', | ||
if (this.destroyed) { | ||
(_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.abort(); | ||
(_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
return; | ||
@@ -284,3 +284,6 @@ } | ||
} | ||
this.destroy(error); | ||
// This is a workaround for https://github.com/nodejs/node/issues/33335 | ||
if (!this.destroyed) { | ||
this.destroy(error); | ||
} | ||
} | ||
@@ -303,2 +306,5 @@ })(options); | ||
} | ||
if (is_1.default.urlInstance(options.url)) { | ||
options.url = new url_1.URL(options.url.toString()); | ||
} | ||
} | ||
@@ -359,7 +365,11 @@ // TODO: Deprecate URL options in Got 12. | ||
} | ||
options.searchParams = new url_1.URLSearchParams(options.searchParams); | ||
const searchParameters = new url_1.URLSearchParams(options.searchParams); | ||
// `normalizeArguments()` is also used to merge options | ||
(_a = defaults === null || defaults === void 0 ? void 0 : defaults.searchParams) === null || _a === void 0 ? void 0 : _a.forEach((value, key) => { | ||
options.searchParams.append(key, value); | ||
// Only use default if one isn't already defined | ||
if (!searchParameters.has(key)) { | ||
searchParameters.append(key, value); | ||
} | ||
}); | ||
options.searchParams = searchParameters; | ||
} | ||
@@ -423,5 +433,16 @@ } | ||
} | ||
// Update `username` & `password` | ||
options.url.username = options.username; | ||
options.url.password = options.password; | ||
// Update `username` | ||
if (options.username === '') { | ||
options.username = options.url.username; | ||
} | ||
else { | ||
options.url.username = options.username; | ||
} | ||
// Update `password` | ||
if (options.password === '') { | ||
options.password = options.url.password; | ||
} | ||
else { | ||
options.url.password = options.password; | ||
} | ||
} | ||
@@ -607,2 +628,3 @@ // `options.cookieJar` | ||
const { url } = options; | ||
this[kOriginalResponse] = response; | ||
if (options.decompress) { | ||
@@ -695,2 +717,5 @@ response = decompressResponse(response); | ||
if (redirectUrl.hostname !== url.hostname) { | ||
if ('host' in options.headers) { | ||
delete options.headers.host; | ||
} | ||
if ('cookie' in options.headers) { | ||
@@ -952,3 +977,6 @@ delete options.headers.cookie; | ||
} | ||
this.destroy(error); | ||
// This is a workaround for https://github.com/nodejs/node/issues/33335 | ||
if (!this.destroyed) { | ||
this.destroy(error); | ||
} | ||
} | ||
@@ -1037,5 +1065,4 @@ _read() { | ||
// - https://github.com/nodejs/node/issues/32851 | ||
// - https://github.com/nock/nock/issues/1981 | ||
if (!((_a = this[kResponse]) === null || _a === void 0 ? void 0 : _a.complete) && !this[kRequest].destroyed) { | ||
this[kRequest].abort(); | ||
if (!((_a = this[kResponse]) === null || _a === void 0 ? void 0 : _a.complete)) { | ||
this[kRequest].destroy(); | ||
} | ||
@@ -1053,4 +1080,4 @@ } | ||
get aborted() { | ||
var _a; | ||
return Boolean((_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.aborted); | ||
var _a, _b, _c; | ||
return ((_b = (_a = this[kRequest]) === null || _a === void 0 ? void 0 : _a.destroyed) !== null && _b !== void 0 ? _b : this.destroyed) && !((_c = this[kOriginalResponse]) === null || _c === void 0 ? void 0 : _c.complete); | ||
} | ||
@@ -1057,0 +1084,0 @@ get socket() { |
@@ -51,3 +51,3 @@ "use strict"; | ||
}); | ||
request.once('abort', cancelTimeouts); | ||
request.once('close', cancelTimeouts); | ||
once(request, 'response', (response) => { | ||
@@ -54,0 +54,0 @@ once(response, 'end', cancelTimeouts); |
@@ -167,3 +167,6 @@ "use strict"; | ||
} | ||
if (optionsToMerge !== undefined) { | ||
if (optionsToMerge === result.request.options) { | ||
normalizedOptions = result.request.options; | ||
} | ||
else if (optionsToMerge !== undefined) { | ||
normalizedOptions = normalizeArguments(undefined, optionsToMerge, normalizedOptions); | ||
@@ -170,0 +173,0 @@ } |
{ | ||
"name": "got", | ||
"version": "11.1.2", | ||
"version": "11.1.3", | ||
"description": "Human-friendly and powerful HTTP request library for Node.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is too big to display
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
181786
2788