aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http2.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-04-26 16:24:50 +0200
committerLoïc Hoguin <[email protected]>2017-04-26 16:24:50 +0200
commite8c08c95b896bf9d2dd299e5fdbff50f714e8749 (patch)
tree4e024c0974a3e61d6950e0936746d4af3e418f29 /src/gun_http2.erl
parentbc733a2ca5f7d07f997ad6edf184f775b23434aa (diff)
downloadgun-e8c08c95b896bf9d2dd299e5fdbff50f714e8749.tar.gz
gun-e8c08c95b896bf9d2dd299e5fdbff50f714e8749.tar.bz2
gun-e8c08c95b896bf9d2dd299e5fdbff50f714e8749.zip
Use the host header value for authority in h2, if any
Diffstat (limited to 'src/gun_http2.erl')
-rw-r--r--src/gun_http2.erl8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gun_http2.erl b/src/gun_http2.erl
index c0983b6..8f9bae7 100644
--- a/src/gun_http2.erl
+++ b/src/gun_http2.erl
@@ -257,7 +257,11 @@ request(State=#http2_state{socket=Socket, transport=Transport, encode_state=Enco
new_stream(StreamID, StreamRef, nofin, fin,
State#http2_state{stream_id=StreamID + 2, encode_state=EncodeState}).
-prepare_headers(EncodeState, Transport, Method, Host, Port, Path, Headers0) ->
+prepare_headers(EncodeState, Transport, Method, Host0, Port, Path, Headers0) ->
+ Authority = case lists:keyfind(<<"host">>, 1, Headers0) of
+ {_, Host} -> Host;
+ _ -> [Host0, $:, integer_to_binary(Port)]
+ end,
%% @todo We also must remove any header found in the connection header.
Headers1 =
lists:keydelete(<<"host">>, 1,
@@ -272,7 +276,7 @@ prepare_headers(EncodeState, Transport, Method, Host, Port, Path, Headers0) ->
true -> <<"https">>;
false -> <<"http">>
end},
- {<<":authority">>, [Host, $:, integer_to_binary(Port)]},
+ {<<":authority">>, Authority},
{<<":path">>, Path}
|Headers1],
cow_hpack:encode(Headers, EncodeState).