aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2022-11-21 15:46:19 +0100
committerLoïc Hoguin <[email protected]>2022-11-21 15:46:19 +0100
commite960c4e7bac5a6872055638f5291b79c2aafa51f (patch)
treee5f63e10deaf823372b4108bb16d5b7e110fbd6e /src
parent395490ea791cad34fd9130feb37eb145b16c1dde (diff)
downloadgun-e960c4e7bac5a6872055638f5291b79c2aafa51f.tar.gz
gun-e960c4e7bac5a6872055638f5291b79c2aafa51f.tar.bz2
gun-e960c4e7bac5a6872055638f5291b79c2aafa51f.zip
Support positive HTTP/1.0 responses to CONNECT requests
Diffstat (limited to 'src')
-rw-r--r--src/gun_http.erl8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl
index 38806d0..18d019e 100644
--- a/src/gun_http.erl
+++ b/src/gun_http.erl
@@ -301,16 +301,20 @@ handle_head(Data, State=#http_state{opts=Opts,
Authority, Path, Status, Headers, CookieStore0, Opts),
case StreamRef of
{connect, _, _} when Status >= 200, Status < 300 ->
- handle_connect(Rest, State, CookieStore, EvHandler, EvHandlerState, Version, Status, Headers);
+ handle_connect(Rest, State, CookieStore, EvHandler, EvHandlerState, Status, Headers);
_ when Status >= 100, Status =< 199 ->
handle_inform(Rest, State, CookieStore, EvHandler, EvHandlerState, Version, Status, Headers);
_ ->
handle_response(Rest, State, CookieStore, EvHandler, EvHandlerState, Version, Status, Headers)
end.
+%% We handle HTTP/1.0 responses to CONNECT requests the same as HTTP/1.1.
+%% This is because many proxies have historically used HTTP/1.0 for their
+%% response. The HTTP/1.1 specification does not disallow it: servers that
+%% respond positively to a CONNECT request are supposed to implement it.
handle_connect(Rest, State=#http_state{
streams=[Stream=#stream{ref={_, StreamRef, Destination}, reply_to=ReplyTo}|Tail]},
- CookieStore, EvHandler, EvHandlerState0, 'HTTP/1.1', Status, Headers) ->
+ CookieStore, EvHandler, EvHandlerState0, Status, Headers) ->
RealStreamRef = stream_ref(State, StreamRef),
%% @todo If the stream is cancelled we probably shouldn't finish the CONNECT setup.
_ = case Stream of