-
Notifications
You must be signed in to change notification settings - Fork 13
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
WebSocket and relative URLs #20
Comments
@ricea, thoughts? |
WebSocket is a distinct protocol that uses an HTTP handshake. It is not HTTP, and so should not use an HTTP URL. Having magic behaviour for relative URLs is attractive, but probably too magical. You can always do something like
You could even monkey-patch the WebSocket constructor to do this automatically. |
The point of this issue is kind of that people already do write code like that, and it's quite annoying.
Well, the point I was making above was that since the initial negotiation is HTTP, an http scheme url is an acceptable identifier of the connection endpoint. If one takes the url, puts http onto it instead of wss, and fetches it, they should encounter a normal http conversation, albeit one probably ending in a 4xx.
I mean it's just like |
True. I have written code like that, and it certainly is annoying.
That's an interesting point I hadn't considered before. On the other hand, we have a constant problem with people mixing up WebSockets and HTTP, and I don't want to make it any worse. As a philosophical point, I don't like having two ways to do something. If |
@ricea Well, I won't die on the "allow http scheme" hill, but I would like to press on allowing relative urls a bit more. I'm curious what your concern is about this behavior. |
It does seem like a weird ceremony for the WebSocket constructor to mandate ws/wss even though it's immediately just mapped to http/https anyway. I remember the first time I set up web socket handling server side years ago that this obfuscation made it harder to develop an initial understanding of how it worked - it's more misleading than not imo. |
Yeah, I'm not sure I agree with @ricea here. The (If we accept HTTP(S) schemes though we probably first want to normalize them to |
now this is quite interesting... the http scheme hill looks a lot more inviting now. it would be very exciting for changes here can clean up the spec as well. I do think it would be weird if new |
I realised that allowing HTTP(S) URLs and allowing relative URLs are almost the same thing, since you could do I still don't think the ergonomic benefit is worth the added confusion, but if some other browser implemented it I wouldn't object. |
I could probably contribute to chromium but webkit and gecko are a bit outside my expertise. @ricea i assume you're responsible for this area of the spec for chromium, any chance of accepting theoretical work here? |
I think I'd wait until gecko or webkit ship something before accepting a patch to chromium. |
Webkit implemented this recently and upcoming Safari 17 will ship that feature:
would be nice if others catch up also. |
This was fixed by #45. |
…lentin Add support to WebSocket for http: and https: URLs, as well as having them be relative to a base URI. Spec: whatwg/websockets#20 Passes new WPT tests for this in /websockets, with other tests unaffected. Differential Revision: https://phabricator.services.mozilla.com/D160330
…lentin Add support to WebSocket for http: and https: URLs, as well as having them be relative to a base URI. Spec: whatwg/websockets#20 Passes new WPT tests for this in /websockets, with other tests unaffected. Differential Revision: https://phabricator.services.mozilla.com/D160330
…lentin Add support to WebSocket for http: and https: URLs, as well as having them be relative to a base URI. Spec: whatwg/websockets#20 Passes new WPT tests for this in /websockets, with other tests unaffected. Also updated our tests to expect these URLs to be successful instead of fail. Differential Revision: https://phabricator.services.mozilla.com/D160330
…lentin Add support to WebSocket for http: and https: URLs, as well as having them be relative to a base URI. Spec: whatwg/websockets#20 Passes new WPT tests for this in /websockets, with other tests unaffected. Also updated our tests to expect these URLs to be successful instead of fail. Differential Revision: https://phabricator.services.mozilla.com/D160330
…lentin Add support to WebSocket for http: and https: URLs, as well as having them be relative to a base URI. Spec: whatwg/websockets#20 Passes new WPT tests for this in /websockets, with other tests unaffected. Differential Revision: https://phabricator.services.mozilla.com/D160330 UltraBlame original commit: f27806eac17bc15be1f23b196f866c769b74e327
…lentin Add support to WebSocket for http: and https: URLs, as well as having them be relative to a base URI. Spec: whatwg/websockets#20 Passes new WPT tests for this in /websockets, with other tests unaffected. Also updated our tests to expect these URLs to be successful instead of fail. Differential Revision: https://phabricator.services.mozilla.com/D160330 UltraBlame original commit: e57780f6a56b73423be1fc35ef431877957bccae
…lentin Add support to WebSocket for http: and https: URLs, as well as having them be relative to a base URI. Spec: whatwg/websockets#20 Passes new WPT tests for this in /websockets, with other tests unaffected. Differential Revision: https://phabricator.services.mozilla.com/D160330 UltraBlame original commit: f27806eac17bc15be1f23b196f866c769b74e327
…lentin Add support to WebSocket for http: and https: URLs, as well as having them be relative to a base URI. Spec: whatwg/websockets#20 Passes new WPT tests for this in /websockets, with other tests unaffected. Also updated our tests to expect these URLs to be successful instead of fail. Differential Revision: https://phabricator.services.mozilla.com/D160330 UltraBlame original commit: e57780f6a56b73423be1fc35ef431877957bccae
…lentin Add support to WebSocket for http: and https: URLs, as well as having them be relative to a base URI. Spec: whatwg/websockets#20 Passes new WPT tests for this in /websockets, with other tests unaffected. Differential Revision: https://phabricator.services.mozilla.com/D160330 UltraBlame original commit: f27806eac17bc15be1f23b196f866c769b74e327
…lentin Add support to WebSocket for http: and https: URLs, as well as having them be relative to a base URI. Spec: whatwg/websockets#20 Passes new WPT tests for this in /websockets, with other tests unaffected. Also updated our tests to expect these URLs to be successful instead of fail. Differential Revision: https://phabricator.services.mozilla.com/D160330 UltraBlame original commit: e57780f6a56b73423be1fc35ef431877957bccae
For folks affected by the change in browser behavior, here's the status as of today (2024-05-10):
The previously-mentioned #45 has relevant links to track the implementations. |
This is shipping in Chromium 125: https://chromestatus.com/feature/5848709993857024 |
Relative URLs are good, and most assets on the web can enjoy usage of them (images, videos, flash objects, EventSource, etc), but the WebSocket constructor does not support them.
Presumably this is due to requiring a
ws
orwss
protocol, but I would pose that usinghttp
andhttps
is actually fine for WebSockets, as it accurately represents the method by which they acquire a connection.So all together:
The text was updated successfully, but these errors were encountered: