aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_http2.erl7
-rw-r--r--src/cowboy_req.erl2
2 files changed, 7 insertions, 2 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.
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index 7b5cc5b..d8fe70d 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -110,7 +110,7 @@
method => binary(),
scheme => binary(),
host => binary(),
- port => binary(),
+ port => inet:port_number(),
qs => binary()
}.
-export_type([push_opts/0]).