Update checked-in dependencies
This commit is contained in:
parent
55ff016766
commit
313daefcef
1570 changed files with 4230 additions and 228668 deletions
14
node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/MockHttpSocket.ts
generated
vendored
14
node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/MockHttpSocket.ts
generated
vendored
|
|
@ -181,6 +181,20 @@ export class MockHttpSocket extends MockSocket {
|
|||
const socket = this.createConnection()
|
||||
this.originalSocket = socket
|
||||
|
||||
/**
|
||||
* @note Inherit the original socket's connection handle.
|
||||
* Without this, each push to the mock socket results in a
|
||||
* new "connection" listener being added (i.e. buffering pushes).
|
||||
* @see https://github.com/nodejs/node/blob/b18153598b25485ce4f54d0c5cb830a9457691ee/lib/net.js#L734
|
||||
*/
|
||||
if ('_handle' in socket) {
|
||||
Object.defineProperty(this, '_handle', {
|
||||
value: socket._handle,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
})
|
||||
}
|
||||
|
||||
// If the developer destroys the socket, destroy the original connection.
|
||||
this.once('error', (error) => {
|
||||
socket.destroy(error)
|
||||
|
|
|
|||
29
node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/index.ts
generated
vendored
29
node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/index.ts
generated
vendored
|
|
@ -25,12 +25,37 @@ export class ClientRequestInterceptor extends Interceptor<HttpRequestEventMap> {
|
|||
}
|
||||
|
||||
protected setup(): void {
|
||||
const { get: originalGet, request: originalRequest } = http
|
||||
const {
|
||||
ClientRequest: OriginalClientRequest,
|
||||
get: originalGet,
|
||||
request: originalRequest,
|
||||
} = http
|
||||
const { get: originalHttpsGet, request: originalHttpsRequest } = https
|
||||
|
||||
const onRequest = this.onRequest.bind(this)
|
||||
const onResponse = this.onResponse.bind(this)
|
||||
|
||||
// Support requests performed via the `ClientRequest` constructor directly.
|
||||
http.ClientRequest = new Proxy(http.ClientRequest, {
|
||||
construct: (target, args: Parameters<typeof http.request>) => {
|
||||
const [url, options, callback] = normalizeClientRequestArgs(
|
||||
'http:',
|
||||
args
|
||||
)
|
||||
|
||||
// Create a mock agent instance appropriate for the request protocol.
|
||||
const Agent = options.protocol === 'https:' ? MockHttpsAgent : MockAgent
|
||||
const mockAgent = new Agent({
|
||||
customAgent: options.agent,
|
||||
onRequest,
|
||||
onResponse,
|
||||
})
|
||||
options.agent = mockAgent
|
||||
|
||||
return Reflect.construct(target, [url, options, callback])
|
||||
},
|
||||
})
|
||||
|
||||
http.request = new Proxy(http.request, {
|
||||
apply: (target, thisArg, args: Parameters<typeof http.request>) => {
|
||||
const [url, options, callback] = normalizeClientRequestArgs(
|
||||
|
|
@ -112,6 +137,8 @@ export class ClientRequestInterceptor extends Interceptor<HttpRequestEventMap> {
|
|||
recordRawFetchHeaders()
|
||||
|
||||
this.subscriptions.push(() => {
|
||||
http.ClientRequest = OriginalClientRequest
|
||||
|
||||
http.get = originalGet
|
||||
http.request = originalRequest
|
||||
|
||||
|
|
|
|||
3
node_modules/@mswjs/interceptors/src/utils/fetchUtils.ts
generated
vendored
3
node_modules/@mswjs/interceptors/src/utils/fetchUtils.ts
generated
vendored
|
|
@ -90,8 +90,9 @@ export class FetchResponse extends Response {
|
|||
const finalBody = FetchResponse.isResponseWithBody(status) ? body : null
|
||||
|
||||
super(finalBody, {
|
||||
...init,
|
||||
status: safeStatus,
|
||||
statusText: init.statusText,
|
||||
headers: init.headers,
|
||||
})
|
||||
|
||||
if (status !== safeStatus) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue