Nils Langner
Nils Langner

Reputation: 303

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

I am trying to get the HTTP version of a response I get using Puppeteer 1.19.0. I hoped it was part of the response object but it was not.

Is there a way to retrieve the version like h2 or http/1.1?

I did not find any pieces of information within the documentation.

Upvotes: 1

Views: 843

Answers (1)

Yevhen Laichenkov
Yevhen Laichenkov

Reputation: 8672

You can easily get it with evaluate function:

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

Upvotes: 3

Related Questions