puppeteer/docs/api/puppeteer.httprequest.redirectchain.md
jrandolf f07ad2c661
fix: update documentation on configuring puppeteer (#9150)
This PR updates the docs regarding configuring puppeteer. In addition,
some changes have been made to the documentation generator to show
default values on the documentation site.

Also fixes: https://github.com/puppeteer/puppeteer/pull/9144
2022-10-24 09:07:05 +02:00

1.1 KiB

sidebar_label
HTTPRequest.redirectChain

HTTPRequest.redirectChain() method

A redirectChain is a chain of requests initiated to fetch a resource.

Signature:

class HTTPRequest {
  redirectChain(): HTTPRequest[];
}

Returns:

HTTPRequest[]

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:

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:

const response = await page.goto('https://google.com');
const chain = response.request().redirectChain();
console.log(chain.length); // 0