MEDIUM: server/backend: implement websocket protocol selection
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 18 Oct 2021 12:39:57 +0000 (14:39 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 3 Nov 2021 15:24:48 +0000 (16:24 +0100)
commit9c3251d1087061f3a0c88f69b8f62ec1f9324bd7
tree35e74c15108afacd197bfb00e82f24b07cd287b7
parentac03ef26e8b81461c2585cc42c1bbaa2ceb878ee
MEDIUM: server/backend: implement websocket protocol selection

Handle properly websocket streams if the server uses an ALPN with both
h1 and h2. Add a new field h2_ws in the server structure. If set to off,
reuse is automatically disable on backend and ALPN is forced to http1.x
if possible. Nothing is done if on.

Implement a mechanism to be able to use a different http version for
websocket streams. A new server member <ws> represents the algorithm to
select the protocol. This can overrides the server <proto>
configuration. If the connection uses ALPN for proto selection, it is
updated for websocket streams to select the right protocol.

Three mode of selection are implemented :
- auto : use the same protocol between non-ws and ws streams. If ALPN is
  use, try to update it to "http/1.1"; this is only done if the server
  ALPN contains "http/1.1".
- h1 : use http/1.1
- h2 : use http/2.0; this requires the server to support RFC8441 or an
  error will be returned by haproxy.
include/haproxy/server-t.h
include/haproxy/server.h
src/backend.c
src/server.c