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

When a path is in a connect url, should the request body include a trailing slash? #394

Closed
nuclearace opened this issue Sep 30, 2017 · 7 comments

Comments

@nuclearace
Copy link
Contributor

nuclearace commented Sep 30, 2017

@daltoniam I'm noticing that socket.io servers aren't picking up WebSockets transports from my socket.io-client. After doing some digging I've found that this bit of code does not add a trailing slash if the path is not empty. Is this valid, or is this something we should fix here, or do I need to dig around more?

@nuclearace
Copy link
Contributor Author

Example:

let ws = WebSocket(url: URL(string: "ws://localhost:8080/test/?transport=websocket")!)

@nuclearace
Copy link
Contributor Author

It seems whether or not to have a trailing closure depends on the server configuration. However, this code doesn't seem to ever include a trailing / when given a path in the url.

@daltoniam
Copy link
Owner

I personally have seen it both way. I tried to research some of the RFC specs to see what the right behavior was, but best I found was this:

 The authority component is preceded by a double slash "//" and is
   terminated by the next slash "/", question-mark "?", or by the end of
   the URI.  Within the authority component, the characters ";", ":",
   "@", "?", and "/" are reserved.

https://tools.ietf.org/html/rfc2396#section-3.2

That seems to line up with my personal experience that it can be either way, but that all being said, changing it isn't difficult if we need. I would think we might want to dig deeper though, as it is doesn't seem to fall out side of the RFC and could be something else.

Also I just tested adding puts "query: #{handshake.query}" into the ws-server.rb in the SimpleTest and it was able to create a proper hash out of them: query: {"transport"=>"websocket"}.

@nuclearace
Copy link
Contributor Author

Yeah I agree that this seems like something that should be looked into deeper. Unfortunately I can't update to 3.0 in one of my libs since node's WS server doesn't seem to like differing paths. But adding some config to Starscream to append a trailing slash also feels a bit tacked on.

@daltoniam
Copy link
Owner

I checked in master what should hopefully be a simple fix. I figure it makes more sense to have Starscream make a simple change then try to make every server conform to the expected RFC. Might be a bit tacked on, but from what we found from #392, I'd think it is safer to keep the behavior the same as it use to be versus trying to track down issues with WebSocket servers. Let me know if that fixes it and I will do a 3.0.2 release.

@nuclearace
Copy link
Contributor Author

I can confirm that this works.

@daltoniam
Copy link
Owner

I had to do a slightly different change as I noticed the fix I did broke the Autobahn test suite URLs. I updated the path creation to take exactly whatever the URL had it. Version 3.0.2 has been released and fixes this issue.

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

No branches or pull requests

2 participants