Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add User-Agent with Playwright version to WebSocket requests #1729

Closed
wants to merge 1 commit into from

Conversation

headlesstesting
Copy link

This adds a Playwright: {version} user-agent header to WebSocket requests.

The reason why we think this PR is useful, is because for people using Playwright with our service, we can automatically determine the most compatible browser version by looking at the Playwright version string.

This adds a `Playwright: {version}` user-agent header to WebSocket requests.
Copy link
Member

@yury-s yury-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of passing version info in a header sgtm, I'm a bit concerned that this approach may not work if the client runs in a web page in the future.

@JoelEinbinder
Copy link
Contributor

Super interesting patch!

I agree with Yury that it would be nice if this was done in a web compatible way. From my research, it looks like document.cookie or the protocols parameter in the websocket constructor can be used for this. But neither option is very clean.

I'm also interested as to why you want the version number of playwright, but not which browser (firefox, webkit, chromium) that the user wants to connect to. Do you have some other way of distinguishing these connections?

@headlesstesting
Copy link
Author

headlesstesting commented Apr 10, 2020

Hi @JoelEinbinder , @yury-s : your comment about web compatibility makes sense.
Perhaps an alternative solution would indeed be to specify the version with the protocols parameter.

In Javascript:

var ws = new WebSocket('wss://example.com/path', ['Playwright v.x.y'])

Node:

this._ws = new WebSocket(URL, ['Playwright v.x.y'], {
      perMessageDeflate: false,
      maxPayload: 256 * 1024 * 1024, // 256Mb
});

I think this would be better than using document.cookie as that will not work with cross-domain requests?

The browser can be specified with the wsEndpoint, we provide several options:

  • wss://chrome.headlesstesting.com
  • wss://firefox.headlesstesting.com
  • ...

@aslushnikov
Copy link
Contributor

So what is the status of this? It hasn't been updated for a few months and doesn't seem to attract much interest...

@headlesstesting did you guys workaround this on your end?

@aslushnikov
Copy link
Contributor

aslushnikov commented Jun 25, 2020

I guess it's not relevant any more :)

@headlesstesting
Copy link
Author

Hi, we've not pursued this, perhaps at a later stage, we can come back with a new PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants