如何在 puppeteer 中获取 (http) 协议版本?

How to get the (http) protocol version in puppeteer?

我正在尝试获取使用 Puppeteer 1.19.0 获得的响应的 HTTP 版本。我希望它是响应对象的一部分,但它不是。

有没有办法像 h2http/1.1 那样检索版本?

我没有在文档中找到任何信息。

使用evaluate函数即可轻松获取:

await page.goto('https://google.com');
const httpVersion = await page.evaluate(() => performance.getEntries()[0].nextHopProtocol);
console.log('HTTP version: ', httpVersion);