11# Mint.WebSocket
22
3- HTTP/1 and HTTP/2 WebSocket support for Mint 🌱
3+ (Unofficial) HTTP/1 and HTTP/2 WebSocket support for Mint 🌱
4+
5+ ## What is Mint?
6+
7+ Mint is a _ functional_ HTTP/1 and HTTP/2 client library written in Elixir.
8+
9+ Why does it matter that it's functional? Isn't Elixir functional?
10+
11+ Well, Existing WebSocket implementations like
12+ [ ` :gun ` ] ( https://github.com/ninenines/gun ) ,
13+ [ ` :websocket_client ` ] ( https://github.com/jeremyong/websocket_client ) ,
14+ or [ ` WebSockex ` ] ( https://github.com/Azolo/websockex ) work by spawning and
15+ passing messages among processes. This is a very convenient interface in
16+ Elixir and Erlang, but it does not allow the author much control over
17+ the WebSocket connection.
18+
19+ Instead ` Mint.WebSocket ` is process-less: the entire HTTP and WebSocket
20+ states are kept in immutable datastructures. This enables authors of
21+ WebSocket clients a more fine-grained control over the connections:
22+ ` Mint.WebSocket ` does not prescribe a process archicture.
23+
24+ For more information, check out
25+ [ Mint#Usage] ( https://github.com/elixir-mint/mint#usage ) .
426
527## Spec conformance
628
@@ -14,6 +36,22 @@ produced by the Autobahn|Testsuite is uploaded on each push to main.
1436See the report here:
1537https://mint-websocket.nyc3.digitaloceanspaces.com/autobahn/index.html
1638
39+ ## A Quick Note About HTTP/2
40+
41+ HTTP/2 WebSockets are not a built-in feature of HTTP/2. rfc8441 is an extension
42+ to the HTTP/2 protocol and server libraries are not obliged to implement it.
43+ In the current landscape, very few server libraries support the HTTP/2
44+ extended CONNECT method which bootstraps WebSockets.
45+
46+ If ` Mint.WebSocket.upgrade/4 ` returns
47+
48+ ``` elixir
49+ {:error , conn, %Mint .WebSocketError {reason: :extended_connect_disabled }}
50+ ```
51+
52+ Then the server does not support HTTP/2 WebSockets or does not have them
53+ enabled.
54+
1755## Usage
1856
1957` Mint.WebSocket ` piggybacks much of the existing ` Mint.HTTP ` API. For example,
0 commit comments