webRequest.BlockingResponse
An object of this type is returned by event listeners that have set "blocking"
in their extraInfoSpec
argument.
By setting particular properties in BlockingResponse
, the listener can modify network requests.
Note that you can't set all this object's properties in every listener: the properties you can set are dependent on the event that triggered this listener, as detailed below.
Type
Values of this type are objects. They contain the following properties:
authCredentials
Optional-
object
. If set, the request is made using the given credentials. You can only set this property inonAuthRequired
. TheauthCredentials
property is an object with the following properties: cancel
Optional-
boolean
. Iftrue
, the request is cancelled. You can only set this property inonBeforeRequest
,onBeforeSendHeaders
,onHeadersReceived
, andonAuthRequired
. redirectUrl
Optional-
string
. This is a URL, and if set, the original request is redirected to that URL. You can only set this property inonBeforeRequest
oronHeadersReceived
.Redirections to non-HTTP schemes such as
data:
are allowed. Redirects use the same request method as the original request unless initiated fromonHeadersReceived
stage, in which case the redirect uses the GET method.If an extension wants to redirect a public (e.g. HTTPS) URL to an extension page, the extension's manifest.json file must contain a web_accessible_resources key that lists the URL for the extension page.
requestHeaders
Optional-
webRequest.HttpHeaders
. This is anHttpHeaders
object, an array in which each object represents a header. If set, the request is made with these headers rather than the original headers. You can only set this property inonBeforeSendHeaders
. responseHeaders
Optional-
webRequest.HttpHeaders
. This is anHttpHeaders
object, an array in which each object represents a header. If set, the server is assumed to have responded with these response headers instead of the originals. You can only set this property inonHeadersReceived
. If multiple extensions attempt to set the same header (for example,Content-Security-Policy
), only one of the changes will be successful. upgradeToSecure
Optional-
boolean
. If set totrue
and the original request is an HTTP request, this will prevent the original request from being sent and instead make a secure (HTTPS) request. If any extension returnsredirectUrl
inonBeforeRequest
, thenupgradeToSecure
will be ignored for that request. You can only set this property inonBeforeRequest
.
Browser compatibility
BCD tables only load in the browser
Note: This API is based on Chromium's chrome.webRequest
API. This documentation is derived from web_request.json
in the Chromium code.