aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-10-29 21:08:12 +0000
committerLoïc Hoguin <[email protected]>2017-10-29 21:08:12 +0000
commit438239358908090bdf05ecdeb4c7dbaf089a00df (patch)
treea2d0ffd4e254d54d0473542251233472983be05b /src/gun_http.erl
parentb33e53d64b2a15d7f4e9c4445ee62ab354aabaae (diff)
downloadgun-438239358908090bdf05ecdeb4c7dbaf089a00df.tar.gz
gun-438239358908090bdf05ecdeb4c7dbaf089a00df.tar.bz2
gun-438239358908090bdf05ecdeb4c7dbaf089a00df.zip
Add support for informational responses
Diffstat (limited to 'src/gun_http.erl')
-rw-r--r--src/gun_http.erl12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gun_http.erl b/src/gun_http.erl
index 204ce4a..3837bb3 100644
--- a/src/gun_http.erl
+++ b/src/gun_http.erl
@@ -174,6 +174,9 @@ handle_head(Data, State=#http_state{version=ClientVersion,
case {Status, StreamRef} of
{101, {websocket, _, WsKey, WsExtensions, WsOpts}} ->
ws_handshake(Rest2, State, Headers, WsKey, WsExtensions, WsOpts);
+ {_, _} when Status >= 100, Status =< 199 ->
+ ReplyTo ! {gun_inform, self(), stream_ref(StreamRef), Status, Headers},
+ handle(Rest2, State);
_ ->
In = response_io_from_headers(Method, Version, Status, Headers),
IsFin = case In of head -> fin; _ -> nofin end,
@@ -181,11 +184,7 @@ handle_head(Data, State=#http_state{version=ClientVersion,
false ->
ok;
true ->
- StreamRef2 = case StreamRef of
- {websocket, SR, _, _, _} -> SR;
- _ -> StreamRef
- end,
- ReplyTo ! {gun_response, self(), StreamRef2,
+ ReplyTo ! {gun_response, self(), stream_ref(StreamRef),
IsFin, Status, Headers},
case IsFin of
fin -> undefined;
@@ -215,6 +214,9 @@ handle_head(Data, State=#http_state{version=ClientVersion,
end
end.
+stream_ref({websocket, StreamRef, _, _, _}) -> StreamRef;
+stream_ref(StreamRef) -> StreamRef.
+
send_data_if_alive(<<>>, State, nofin) ->
State;
%% @todo What if we receive data when the HEAD method was used?