mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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 {
|
||||
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', () =>
|
||||
|
Loading…
Reference in New Issue
Block a user