HTTPRequest.redirectChain() 方法
redirectChain 是为获取资源而发起的一系列请求构成的链。
签名
class HTTPRequest {
abstract redirectChain(): HTTPRequest[];
}
返回值:
请求链——如果服务器至少响应一次重定向,则该链将包含所有被重定向的请求。
备注
redirectChain 在同一条链的所有请求之间共享。
例如,如果网站 http://example.com 有一个指向 https://example.com 的重定向,那么该链将包含一个请求:
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'
如果网站 https://google.com 没有重定向,那么该链将为空:
const response = await page.goto('https://google.com');
const chain = response.request().redirectChain();
console.log(chain.length); // 0