aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_clear.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-04-01 18:02:59 +0200
committerLoïc Hoguin <[email protected]>2020-04-01 18:02:59 +0200
commita8a26897274c798cb95d3a2e9e8da1215c2da78a (patch)
treebff75e56a0009b2aedc415f724bebcd31b6d769e /src/cowboy_clear.erl
parentbcef70818be1b0fdf5d3e52e9b7c490882218b45 (diff)
downloadcowboy-a8a26897274c798cb95d3a2e9e8da1215c2da78a.tar.gz
cowboy-a8a26897274c798cb95d3a2e9e8da1215c2da78a.tar.bz2
cowboy-a8a26897274c798cb95d3a2e9e8da1215c2da78a.zip
Fix h2spec "invalid preface sequence" test
Introduce a currently undocumented option to allow disabling cowboy_http when using a clear listener.
Diffstat (limited to 'src/cowboy_clear.erl')
-rw-r--r--src/cowboy_clear.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cowboy_clear.erl b/src/cowboy_clear.erl
index 0af734f..4f3a234 100644
--- a/src/cowboy_clear.erl
+++ b/src/cowboy_clear.erl
@@ -41,7 +41,16 @@ connection_process(Parent, Ref, Transport, Opts) ->
undefined
end,
{ok, Socket} = ranch:handshake(Ref),
- init(Parent, Ref, Socket, Transport, ProxyInfo, Opts, cowboy_http).
+ %% Use cowboy_http2 directly only when 'http' is missing.
+ %% Otherwise switch to cowboy_http2 from cowboy_http.
+ %%
+ %% @todo Extend this option to cowboy_tls and allow disabling
+ %% the switch to cowboy_http2 in cowboy_http. Also document it.
+ Protocol = case maps:get(protocols, Opts, [http2, http]) of
+ [http2] -> cowboy_http2;
+ [_|_] -> cowboy_http
+ end,
+ init(Parent, Ref, Socket, Transport, ProxyInfo, Opts, Protocol).
init(Parent, Ref, Socket, Transport, ProxyInfo, Opts, Protocol) ->
_ = case maps:get(connection_type, Opts, supervisor) of