WebSocket frame codec (RFC 6455)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-requests: extend MDX coverage to lib/{features,h1,oauth,parsing}/*.mli

Adds (mdx ...) stanzas to each subdir dune file (per-dune is the only
working unit; dune-mdx (files ...) doesn't recurse).

Examples rewritten as executable specs: top-level construction +
asserts where the API is pure (parsing/link, oauth/oauth config,
features/auth/cache/proxy/retry); let-run for genuine side effects
(h1/http_write Buf_write, features/proxy_tunnel TCP, features/signature
Eio clock).

+14 -15
+12 -13
lib/handshake.mli
··· 8 8 (** WebSocket HTTP upgrade handshake (RFC 6455 §4). 9 9 10 10 A WebSocket connection is established by upgrading an HTTP/1.1 connection 11 - using the [Upgrade] mechanism. This module provides the helpers used by 12 - that handshake: client key generation, server-side accept-value 13 - computation, validation, and protocol/extension negotiation. 11 + using the [Upgrade] mechanism. This module provides the helpers used by that 12 + handshake: client key generation, server-side accept-value computation, 13 + validation, and protocol/extension negotiation. 14 14 15 - The on-the-wire frame codec lives in {!module:Websocket} (sibling 16 - module). Use this module for the handshake; switch to {!Websocket.encode} 17 - / {!Websocket.decode} once the connection is upgraded. 15 + The on-the-wire frame codec lives in {!module:Websocket} (sibling module). 16 + Use this module for the handshake; switch to {!Websocket.encode} / 17 + {!Websocket.decode} once the connection is upgraded. 18 18 19 19 Sec-WebSocket-Accept is deterministic given the client key (RFC 6455 §4.2.2 20 20 test vector): 21 21 {[ 22 22 let () = 23 - assert 24 - (Websocket.Handshake.compute_accept ~key:"dGhlIHNhbXBsZSBub25jZQ==" 25 - = "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="); 26 - assert 27 - (Websocket.Handshake.validate_accept 28 - ~key:"dGhlIHNhbXBsZSBub25jZQ==" 29 - ~accept:"s3pPLMBiTxaQ9kYGzzhZRbK+xOo="); 23 + assert ( 24 + Websocket.Handshake.compute_accept ~key:"dGhlIHNhbXBsZSBub25jZQ==" 25 + = "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="); 26 + assert ( 27 + Websocket.Handshake.validate_accept ~key:"dGhlIHNhbXBsZSBub25jZQ==" 28 + ~accept:"s3pPLMBiTxaQ9kYGzzhZRbK+xOo="); 30 29 assert (Websocket.Handshake.protocol_version = "13") 31 30 ]} 32 31
+2 -2
lib/websocket.mli
··· 2 2 3 3 This module exposes both layers of RFC 6455: 4 4 5 - - The frame codec at the top of the module — encode/decode frames, 6 - masking, fragmentation, ping/pong, close. 5 + - The frame codec at the top of the module — encode/decode frames, masking, 6 + fragmentation, ping/pong, close. 7 7 - The HTTP upgrade handshake under {!module:Handshake} — Sec-WebSocket-Key 8 8 generation, Sec-WebSocket-Accept computation, protocol/extension 9 9 negotiation, request/response header builders.