feat: add User-Agent with Puppeteer version to WebSocket request (#5614)
This will add the User-Agent header to WebSocket requests.
This commit is contained in:
parent
300be5d167
commit
6a2bf0aaba
@ -18,11 +18,16 @@ import NodeWebSocket from 'ws';
|
|||||||
|
|
||||||
export class NodeWebSocketTransport implements ConnectionTransport {
|
export class NodeWebSocketTransport implements ConnectionTransport {
|
||||||
static create(url: string): Promise<NodeWebSocketTransport> {
|
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) => {
|
return new Promise((resolve, reject) => {
|
||||||
const ws = new NodeWebSocket(url, [], {
|
const ws = new NodeWebSocket(url, [], {
|
||||||
followRedirects: true,
|
followRedirects: true,
|
||||||
perMessageDeflate: false,
|
perMessageDeflate: false,
|
||||||
maxPayload: 256 * 1024 * 1024, // 256Mb
|
maxPayload: 256 * 1024 * 1024, // 256Mb
|
||||||
|
headers: {
|
||||||
|
'User-Agent': `Puppeteer ${pkg.version}`,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.addEventListener('open', () =>
|
ws.addEventListener('open', () =>
|
||||||
|
Loading…
Reference in New Issue
Block a user