From 6e8b907ae25a7a988abbcd7206b978028c36f47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 18 Apr 2017 14:06:34 +0200 Subject: Pass the HTTP/2 switch_protocol event to stream handlers To accomplish this the code for sending the 101 response was moved to the cowboy_http2 module. --- src/cowboy_http.erl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/cowboy_http.erl') diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index e6cceae..983d95f 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -635,6 +635,7 @@ request(Buffer, State0=#state{ref=Ref, transport=Transport, peer=Peer, in_stream %% HTTP/2 upgrade. +%% @todo We must not upgrade to h2c over a TLS connection. is_http2_upgrade(#{<<"connection">> := Conn, <<"upgrade">> := Upgrade, <<"http2-settings">> := HTTP2Settings}, 'HTTP/1.1') -> Conns = cow_http_hd:parse_connection(Conn), @@ -675,13 +676,6 @@ http2_upgrade(State=#state{parent=Parent, ref=Ref, socket=Socket, transport=Tran %% Always half-closed stream coming from this side. try cow_http_hd:parse_http2_settings(HTTP2Settings) of Settings -> - %% @todo We should invoke cowboy_stream:info for this stream, - %% with a switch_protocol tuple. - Transport:send(Socket, cow_http:response(101, 'HTTP/1.1', maps:to_list(#{ - <<"connection">> => <<"Upgrade">>, - <<"upgrade">> => <<"h2c">> - }))), - %% @todo Possibly redirect the request if it was https. _ = cancel_request_timeout(State), cowboy_http2:init(Parent, Ref, Socket, Transport, Opts, Peer, Buffer, Settings, Req) catch _:_ -> -- cgit v1.2.3