Comparing version 5.22.1 to 5.23.0
@@ -22,3 +22,5 @@ # Class: ProxyAgent | ||
* **auth** `string` (**deprecated**) - Use token. | ||
* **clientFactory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)` | ||
* **clientFactory** `(origin: URL, opts: Object) => Dispatcher` (optional) - Default: `(origin, opts) => new Pool(origin, opts)` | ||
* **requestTls** `BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the request. See [TLS](https://nodejs.org/api/tls.html#tlsconnectoptions-callback). | ||
* **proxyTls** `BuildOptions` (optional) - Options object passed when creating the underlying socket via the connector builder for the proxy server. See [TLS](https://nodejs.org/api/tls.html#tlsconnectoptions-callback). | ||
@@ -25,0 +27,0 @@ Examples: |
@@ -0,1 +1,2 @@ | ||
const { addAbortListener } = require('../core/util') | ||
const { RequestAbortedError } = require('../core/errors') | ||
@@ -32,7 +33,3 @@ | ||
if ('addEventListener' in self[kSignal]) { | ||
self[kSignal].addEventListener('abort', self[kListener]) | ||
} else { | ||
self[kSignal].addListener('abort', self[kListener]) | ||
} | ||
addAbortListener(self[kSignal], self[kListener]) | ||
} | ||
@@ -39,0 +36,0 @@ |
@@ -158,2 +158,3 @@ // Ported from https://github.com/nodejs/undici/pull/907 | ||
} | ||
let signalListenerCleanup | ||
if (signal) { | ||
@@ -164,3 +165,3 @@ if (typeof signal !== 'object' || !('aborted' in signal)) { | ||
util.throwIfAborted(signal) | ||
signal.addEventListener('abort', abortFn, { once: true }) | ||
signalListenerCleanup = util.addAbortListener(signal, abortFn) | ||
} | ||
@@ -178,4 +179,6 @@ try { | ||
} finally { | ||
if (signal) { | ||
signal.removeEventListener('abort', abortFn) | ||
if (typeof signalListenerCleanup === 'function') { | ||
signalListenerCleanup() | ||
} else if (signalListenerCleanup) { | ||
signalListenerCleanup[Symbol.dispose]() | ||
} | ||
@@ -182,0 +185,0 @@ } |
@@ -425,2 +425,20 @@ 'use strict' | ||
let events | ||
function addAbortListener (signal, listener) { | ||
if (typeof Symbol.dispose === 'symbol') { | ||
if (!events) { | ||
events = require('events') | ||
} | ||
if (typeof events.addAbortListener === 'function' && 'aborted' in signal) { | ||
return events.addAbortListener(signal, listener) | ||
} | ||
} | ||
if ('addEventListener' in signal) { | ||
signal.addEventListener('abort', listener, { once: true }) | ||
return () => signal.removeEventListener('abort', listener) | ||
} | ||
signal.addListener('abort', listener) | ||
return () => signal.removeListener('abort', listener) | ||
} | ||
const hasToWellFormed = !!String.prototype.toWellFormed | ||
@@ -473,2 +491,3 @@ | ||
throwIfAborted, | ||
addAbortListener, | ||
nodeMajor, | ||
@@ -475,0 +494,0 @@ nodeMinor, |
@@ -108,3 +108,3 @@ 'use strict' | ||
} else if (util.isFormDataLike(object)) { | ||
const boundary = `----formdata-undici-${Math.random()}`.replace('.', '').slice(0, 32) | ||
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}` | ||
const prefix = `--${boundary}\r\nContent-Disposition: form-data` | ||
@@ -111,0 +111,0 @@ |
@@ -235,10 +235,14 @@ /* globals AbortController */ | ||
// 3. If one of the following is true | ||
// parsedReferrer’s cannot-be-a-base-URL is true, scheme is "about", | ||
// and path contains a single string "client" | ||
// parsedReferrer’s origin is not same origin with origin | ||
// - parsedReferrer’s scheme is "about" and path is the string "client" | ||
// - parsedReferrer’s origin is not same origin with origin | ||
// then set request’s referrer to "client". | ||
// TODO | ||
// 4. Otherwise, set request’s referrer to parsedReferrer. | ||
request.referrer = parsedReferrer | ||
if ( | ||
(parsedReferrer.protocol === 'about:' && parsedReferrer.hostname === 'client') || | ||
(origin && !sameOrigin(parsedReferrer, this[kRealm].settingsObject.baseUrl)) | ||
) { | ||
request.referrer = 'client' | ||
} else { | ||
// 4. Otherwise, set request’s referrer to parsedReferrer. | ||
request.referrer = parsedReferrer | ||
} | ||
} | ||
@@ -340,2 +344,4 @@ } | ||
// Realm. | ||
// TODO: could this be simplified with AbortSignal.any | ||
// (https://dom.spec.whatwg.org/#dom-abortsignal-any) | ||
const ac = new AbortController() | ||
@@ -386,3 +392,3 @@ this[kSignal] = ac.signal | ||
signal.addEventListener('abort', abort, { once: true }) | ||
util.addAbortListener(signal, abort) | ||
requestFinalizer.register(ac, { signal, abort }) | ||
@@ -735,8 +741,7 @@ } | ||
} else { | ||
this.signal.addEventListener( | ||
'abort', | ||
util.addAbortListener( | ||
this.signal, | ||
() => { | ||
ac.abort(this.signal.reason) | ||
}, | ||
{ once: true } | ||
} | ||
) | ||
@@ -743,0 +748,0 @@ } |
{ | ||
"name": "undici", | ||
"version": "5.22.1", | ||
"version": "5.23.0", | ||
"description": "An HTTP/1.1 client, written from scratch for Node.js", | ||
@@ -89,3 +89,3 @@ "homepage": "https://undici.nodejs.org", | ||
"jest": "^29.0.2", | ||
"jsdom": "^21.1.0", | ||
"jsdom": "^22.1.0", | ||
"jsfuzz": "^1.0.15", | ||
@@ -92,0 +92,0 @@ "mocha": "^10.0.0", |
@@ -232,3 +232,3 @@ import { URL } from 'url' | ||
formData(): Promise<never>; | ||
json(): Promise<any>; | ||
json(): Promise<unknown>; | ||
text(): Promise<string>; | ||
@@ -235,0 +235,0 @@ } |
@@ -21,3 +21,3 @@ import { Readable } from "stream"; | ||
*/ | ||
json(): Promise<any> | ||
json(): Promise<unknown> | ||
@@ -24,0 +24,0 @@ /** Consumes and returns the body as a Blob |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
1122830
149
19384
2