ws_h2_upgrade (ws v0.1.1)
View SourceRFC 8441 — Bootstrapping WebSockets with HTTP/2.
This module only deals with the pseudo-header / response-status validation. Actually driving the HTTP/2 stream (sending the request, receiving the response, swapping data frames for WebSocket frames) belongs to the embedder; erlang_h2 already enforces the semantics and the handshake details below mirror that.
Caller responsibilities (server-side): * Before receiving any Extended CONNECT, the HTTP/2 stack must have advertised SETTINGS_ENABLE_CONNECT_PROTOCOL = 1. If the peer sent :protocol without having seen that setting it is the erlang_h2 layer that rejects the stream. * After this module returns {ok, Info}, the embedder issues a 200 response with the headers from response_headers/1 and hands the stream bytes to ws:accept/5.
Caller responsibilities (client-side): * peer_enable_connect_protocol must be true (the peer advertised SETTINGS_ENABLE_CONNECT_PROTOCOL = 1). client_request/4 returns an error when that is not the case.
Summary
Types
Functions
-spec response_headers(request_info()) -> [{binary(), binary()}].
-spec validate_request(pseudo_headers()) -> {ok, request_info()} | {error, term()}.
-spec validate_request(pseudo_headers(), request_opts()) -> {ok, request_info()} | {error, term()}.