docs(api.md): add example to override request headers (#3475)

References #3458.
This commit is contained in:
Andrey Lushnikov 2018-11-01 15:44:04 -07:00 committed by GitHub
parent 2a88690582
commit 8e93eab784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3063,6 +3063,18 @@ Exception is immediately thrown if the request interception is not enabled.
Continues request with optional request overrides. To use this, request interception should be enabled with `page.setRequestInterception`.
Exception is immediately thrown if the request interception is not enabled.
```js
await page.setRequestInterception(true);
page.on('request', request => {
// Override headers
const headers = Object.assign({}, request.headers(), {
foo: 'bar', // set "foo" header
origin: undefined, // remove "origin" header
});
request.continue({headers});
});
```
#### request.failure()
- returns: <?[Object]> Object describing request failure, if any
- `errorText` <[string]> Human-readable error message, e.g. `'net::ERR_FAILED'`.