aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http2.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-05-16 10:42:25 +0200
committerLoïc Hoguin <[email protected]>2018-05-16 10:42:25 +0200
commitd732e74dd589ef3d4271198e22aabd976fb3e3c4 (patch)
treea94dcd785c31944c8bbe68439d7f6bcb9757d5e8 /src/cowboy_http2.erl
parent93e8744e220a88e479a7891c49f2ed304a7c675f (diff)
downloadcowboy-d732e74dd589ef3d4271198e22aabd976fb3e3c4.tar.gz
cowboy-d732e74dd589ef3d4271198e22aabd976fb3e3c4.tar.bz2
cowboy-d732e74dd589ef3d4271198e22aabd976fb3e3c4.zip
Use default port when not given in :authority
Diffstat (limited to 'src/cowboy_http2.erl')
-rw-r--r--src/cowboy_http2.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cowboy_http2.erl b/src/cowboy_http2.erl
index dfda305..d40046e 100644
--- a/src/cowboy_http2.erl
+++ b/src/cowboy_http2.erl
@@ -1119,7 +1119,8 @@ stream_req_init(State=#state{ref=Ref, peer=Peer, sock=Sock, cert=Cert},
StreamID, IsFin, Headers, PseudoHeaders=#{method := Method, scheme := Scheme,
authority := Authority, path := PathWithQs}, BodyLength) ->
try cow_http_hd:parse_host(Authority) of
- {Host, Port} ->
+ {Host, Port0} ->
+ Port = ensure_port(Scheme, Port0),
try cow_http:parse_fullpath(PathWithQs) of
{<<>>, _} ->
stream_malformed(State, StreamID,
@@ -1160,6 +1161,10 @@ stream_req_init(State=#state{ref=Ref, peer=Peer, sock=Sock, cert=Cert},
'The :authority pseudo-header is invalid. (RFC7540 8.1.2.3)')
end.
+ensure_port(<<"http">>, undefined) -> 80;
+ensure_port(<<"https">>, undefined) -> 443;
+ensure_port(_, Port) -> Port.
+
stream_closed(State=#state{socket=Socket, transport=Transport}, StreamID, _) ->
Transport:send(Socket, cow_http2:rst_stream(StreamID, stream_closed)),
State.