Skip to content

Commit

Permalink
feat: add User-Agent with Puppeteer version to WebSocket request (#5614)
Browse files Browse the repository at this point in the history
This will add the User-Agent header to WebSocket requests.
  • Loading branch information
headlesstesting committed Sep 15, 2021
1 parent 300be5d commit 6a2bf0a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/node/NodeWebSocketTransport.ts
Expand Up @@ -18,11 +18,16 @@ import NodeWebSocket from 'ws';

export class NodeWebSocketTransport implements ConnectionTransport {
static create(url: string): Promise<NodeWebSocketTransport> {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg = require('../../../../package.json');
return new Promise((resolve, reject) => {
const ws = new NodeWebSocket(url, [], {
followRedirects: true,
perMessageDeflate: false,
maxPayload: 256 * 1024 * 1024, // 256Mb
headers: {
'User-Agent': `Puppeteer ${pkg.version}`,
},
});

ws.addEventListener('open', () =>
Expand Down

0 comments on commit 6a2bf0a

Please sign in to comment.