feat: socket-protocol-parsing service - #8302
harrysolovay wants to merge 3 commits into
Conversation
Adds a `SocketProtocols` service that reads the `Sec-WebSocket-Protocol` header from the current `HttpServerRequest` and exposes the parsed list of sub-protocol names, plus a `Schema` for converting between the header string and an array of trimmed protocol names. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 15b7b7a The changes in this PR will be included in the next version bump. This PR includes changesets to release 31 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
|
looked through this. schema + the request layer are the same shape i was going to add. missing header yields undefined, which is actually the nicer fail-open. empty header still becomes []. that answers the question i asked on #7374. two gaps vs the original issue:
on your note: yeah, export and the socket package pulling tests look good for the happy path. i'd add the empty-token case and a lowercase header, since browsers send i'll drop my claim on #7374. this is yours. |
- Keep the Sec-WebSocket-Protocol schema in effect/unstable/socket and drop empty tokens when decoding, so "a,,b" decodes to ["a", "b"] - Move the service into a new effect/unstable/http/HttpSocketProtocols module along with the header key constant, with the layer exported at module level and its logic inlined in Layer.effect - Add tests for empty tokens and lowercase header names Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Also import the socket protocols schema by name instead of as a namespace, since it is the only member used. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
@ArjunCodess I just addressed your (excellent) feedback – ready for another review |
I kept running into the need to extract socket protocol tokens from the given
HttpServerRequest. Figured I'd propose this util; I'm not sure ifunstable/socketis the correct place for this (vs. in the http module).Adds a SocketProtocols service to
effect/unstable/socketfor reading and parsing the Sec-WebSocket-Protocol request header.