Skip to content

Commit

Permalink
Add User-Agent with Playwright version to WebSocket requests
Browse files Browse the repository at this point in the history
This adds a `Playwright: {version}` user-agent header to WebSocket requests.
  • Loading branch information
headlesstesting authored Apr 9, 2020
1 parent 1b366b0 commit 0289100
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import * as debug from 'debug';
import * as WebSocket from 'ws';
import { helper } from './helper';
import * as pkg from '../package.json';

export type ProtocolRequest = {
id: number;
Expand Down Expand Up @@ -138,6 +139,9 @@ export class WebSocketTransport implements ConnectionTransport {
this._ws = new WebSocket(url, [], {
perMessageDeflate: false,
maxPayload: 256 * 1024 * 1024, // 256Mb
headers: {
'User-Agent' : `Playwright ${pkg.version}`,
}
});
// The 'ws' module in node sometimes sends us multiple messages in a single task.
// In Web, all IO callbacks (e.g. WebSocket callbacks)
Expand Down

0 comments on commit 0289100

Please sign in to comment.