2020-06-04 14:56:45 +00:00
|
|
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
|
|
|
|
[Home](./index.md) > [puppeteer](./puppeteer.md) > [HTTPRequest](./puppeteer.httprequest.md) > [redirectChain](./puppeteer.httprequest.redirectchain.md)
|
|
|
|
|
|
|
|
## HTTPRequest.redirectChain() method
|
|
|
|
|
|
|
|
<b>Signature:</b>
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
redirectChain(): HTTPRequest[];
|
|
|
|
```
|
|
|
|
<b>Returns:</b>
|
|
|
|
|
|
|
|
[HTTPRequest](./puppeteer.httprequest.md)<!-- -->\[\]
|
|
|
|
|
2020-07-03 13:28:45 +00:00
|
|
|
the chain of requests - if a server responds with at least a single redirect, this chain will contain all requests that were redirected.
|
|
|
|
|
|
|
|
## Remarks
|
|
|
|
|
|
|
|
`redirectChain` is shared between all the requests of the same chain.
|
|
|
|
|
|
|
|
For example, if the website `http://example.com` has a single redirect to `https://example.com`<!-- -->, then the chain will contain one request:
|
|
|
|
|
|
|
|
```js
|
|
|
|
const response = await page.goto('http://example.com');
|
|
|
|
const chain = response.request().redirectChain();
|
|
|
|
console.log(chain.length); // 1
|
|
|
|
console.log(chain[0].url()); // 'http://example.com'
|
|
|
|
|
|
|
|
```
|
|
|
|
If the website `https://google.com` has no redirects, then the chain will be empty:
|
|
|
|
|
|
|
|
```js
|
|
|
|
const response = await page.goto('https://google.com');
|
|
|
|
const chain = response.request().redirectChain();
|
|
|
|
console.log(chain.length); // 0
|
|
|
|
|
|
|
|
```
|
|
|
|
|