interceptors
interceptors copied to clipboard
Low-level network interception library.
The standard `node:url` module ships with a `urlToHttpOptions` function that produces `ClientRequest` options from the given url. We can use that instead of the custom logic we have in normalizing...
A proof of concept of using `async_hooks` for request interception. Quite interesting.
This PR aims to solve issue https://github.com/mswjs/msw/issues/778. I took the following approach : - Decorate the global AbortController class - Hold weak references to all controllers created - Once a...
Node.js behaviour: ```js const http = require('http'); const req = http.get('http://nowhere.com/', res => { console.log('response event'); }) req.on('finish', () => console.log('finish')) req.end('', null, () => console.log('callback')) ``` This prints: >...
https://github.com/mswjs/interceptors/blob/main/src/interceptors/ClientRequest/NodeClientRequest.ts#L101 `chunk` must not be undefined and throw: ``` TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received undefined ``` I...
closes #458
I added a failing test. @kettanaito The current implementation of the `end` function is async ([unlike in Node](https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L1073)), which forces us to set `this.finish = true` in the "sync" part...
Following of [this comment](https://github.com/mswjs/interceptors/pull/454#issuecomment-1741754945), I revisited the options parsing rules according to Node.js source and docs, and a few insights: 1. `host` and `hostname` are the same, hostname is preferred...
The `Response` merges the headers, so we don't get the original rawHeaders array.  @kettanaito WDYT? P.S: I fixed a small error in headers, set-cookie is not an array. (easy...
We don't suppress any error **after** the `MockLookupEnd` state. It seems like Node still emits some errors that we might want to suppress or avoid somehow. ```js const { ClientRequestInterceptor...