Merged
Conversation
kickster97
approved these changes
Jan 16, 2026
carlhoerberg
approved these changes
Jan 18, 2026
spuun
added a commit
that referenced
this pull request
Jan 23, 2026
…er (#1637) This fixes some parts that #1621 missed. The specs added in #1621 did only verify that the websocket handler picked the right client handler based on `Sec-WebSocket-Protocol`. What they didn't verify was if `Sec-WebSocket-Protocol` was sent back to the client. Because of how Crystal's `HTTP::WebSocketHandler` and `HTTP::Server:Response#upgrade` works I just copied `HTTP::WebSocketHandler` to make my own fixed version. crystal-lang/crystal#16574 would fix this in the stdlib.
viktorerlingsson
pushed a commit
that referenced
this pull request
Jan 28, 2026
Add support for Sec-WebSocket-Protocol header Implements RFC 6455 sub-protocol negotiation for WebSocket connections, allowing clients to specify whether they want to use AMQP or MQTT via the `Sec-WebSocket-Protocol` header during the WebSocket handshake. Changes: - Parse `Sec-WebSocket-Protocol` header values starting with "amqp" or "mqtt" to determine protocol - Respond with the chosen protocol in the handshake response - Maintain backward compatibility by falling back to path-based detection (`/mqtt`, `/ws/mqtt`) - Default to AMQP when no protocol is specified - Add comprehensive test coverage for both protocols with various header values This allows WebSocket clients to properly negotiate the protocol according to IANA registered WebSocket sub-protocol names. Fixes #1615
viktorerlingsson
pushed a commit
that referenced
this pull request
Jan 28, 2026
…er (#1637) This fixes some parts that #1621 missed. The specs added in #1621 did only verify that the websocket handler picked the right client handler based on `Sec-WebSocket-Protocol`. What they didn't verify was if `Sec-WebSocket-Protocol` was sent back to the client. Because of how Crystal's `HTTP::WebSocketHandler` and `HTTP::Server:Response#upgrade` works I just copied `HTTP::WebSocketHandler` to make my own fixed version. crystal-lang/crystal#16574 would fix this in the stdlib.
kickster97
pushed a commit
that referenced
this pull request
Feb 6, 2026
Add support for Sec-WebSocket-Protocol header Implements RFC 6455 sub-protocol negotiation for WebSocket connections, allowing clients to specify whether they want to use AMQP or MQTT via the `Sec-WebSocket-Protocol` header during the WebSocket handshake. Changes: - Parse `Sec-WebSocket-Protocol` header values starting with "amqp" or "mqtt" to determine protocol - Respond with the chosen protocol in the handshake response - Maintain backward compatibility by falling back to path-based detection (`/mqtt`, `/ws/mqtt`) - Default to AMQP when no protocol is specified - Add comprehensive test coverage for both protocols with various header values This allows WebSocket clients to properly negotiate the protocol according to IANA registered WebSocket sub-protocol names. Fixes #1615
kickster97
pushed a commit
that referenced
this pull request
Feb 6, 2026
…er (#1637) This fixes some parts that #1621 missed. The specs added in #1621 did only verify that the websocket handler picked the right client handler based on `Sec-WebSocket-Protocol`. What they didn't verify was if `Sec-WebSocket-Protocol` was sent back to the client. Because of how Crystal's `HTTP::WebSocketHandler` and `HTTP::Server:Response#upgrade` works I just copied `HTTP::WebSocketHandler` to make my own fixed version. crystal-lang/crystal#16574 would fix this in the stdlib.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for Sec-WebSocket-Protocol header
Implements RFC 6455 sub-protocol negotiation for WebSocket connections, allowing clients to specify whether they want to use AMQP or MQTT via the
Sec-WebSocket-Protocolheader during the WebSocket handshake.Changes:
Sec-WebSocket-Protocolheader values starting with "amqp" or "mqtt" to determine protocol/mqtt,/ws/mqtt)This allows WebSocket clients to properly negotiate the protocol according to IANA registered WebSocket sub-protocol names.
Fixes #1615