Skip to content

Allow Host to be overridden in handshake headers #530

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

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

gordonread
Copy link
Contributor

I had a situation with a thirdparty websocket server which was rejecting the upgrade to a websocket connection (in IXWebSocketHandshake::clientHandshake(...)) with a HTTP 400 (Bad Request) error because the thirdparty server didn't like the format of the "Host:" header being set to "stream.example.com:port", so, e.g.

GET /required/path HTTP:/1.1
Host: stream.example.com:1234

Failed with a HTTP 400 error code (when IXWebSocket expects a HTTP 101 Switching Protocols code), but the following without ":port":

GET /required/path HTTP:/1.1
Host: stream.example.com

Worked OK.

This small change allows the "Host" header to be specified in `ix::WebSocketHttpHeaders", e.g.

ix::WebSocket webSocket{};
ix::WebSocketHttpHeaders headers{};
headers["Host"] = "stream.example.com";
webSocket.SetExtraHeaders(headers);

Will give the desired result.

Added a few test cases.

@bsergean
Copy link
Collaborator

Thanks !

@bsergean bsergean merged commit 0424295 into machinezone:master Nov 10, 2024
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.

2 participants