GO-V.ORG
As seen in

webRequest.StreamFilter.disconnect()

Disconnects the filter from the request. After this, the browser will continue to process the response, but no more filter events will fire, and no more filter function calls will have any effect. Note the difference between this function and close(). With disconnect(), the browser will continue to process any further response data, but it won't be accessible through the filter. With close(), the

Disconnects the filter from the request. After this, the browser will continue to process the response, but no more filter events will fire, and no more filter function calls will have any effect. Note the difference between this function and close(). With `disconnect()`, the browser will continue to process any further response data, but it won't be accessible through the filter. With `close()`, the browser will ignore any response data that hasn't already been passed through to the rendering engine.

You should always call `disconnect()` or `close()` once you don't need to interact with the response any further.

You can't call this function until after the onstart event has fired.

## Syntax

```js-nolint
filter.disconnect()
```

### Parameters

None.

### Return value

None.

## Examples

This example will prepend "preface text" to the response body. It then disconnects, so the original response body will load normally:

```js
function listener(details) {
let filter = browser.webRequest.filterResponseData(details.requestId);

filter.onstart = (event) => {
console.log("started");
let encoder = new TextEncoder();
filter.write(encoder.encode("preface text"));
filter.disconnect();
};
}

browser.webRequest.onBeforeRequest.addListener(
listener,
{ urls: ["https://example.org/"], types: ["main_frame"] },
["blocking"],
);
```

## Browser compatibility

source: MDN Web Docs mirror · page

Cite this

"webRequest.StreamFilter.disconnect()". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/StreamFilter/disconnect

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·