From 2722eca9048f990bd5e8d247d9dc2620320c6020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 16 Aug 2015 23:00:39 +0200 Subject: Handle 204 responses properly Thanks @petrohi for the initial patch. --- src/gun_http.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gun_http.erl') diff --git a/src/gun_http.erl b/src/gun_http.erl index 12fb83c..b1ac4ad 100644 --- a/src/gun_http.erl +++ b/src/gun_http.erl @@ -147,7 +147,7 @@ handle_head(Data, State=#http_state{owner=Owner, version=ClientVersion, {101, {websocket, _, WsKey, WsExtensions, WsProtocols, WsOpts}} -> ws_handshake(Rest2, State, Headers, WsKey, WsExtensions, WsProtocols, WsOpts); _ -> - In = response_io_from_headers(Version, Headers), + In = response_io_from_headers(Version, Status, Headers), IsFin = case In of head -> fin; _ -> nofin end, case IsAlive of false -> @@ -343,7 +343,9 @@ request_io_from_headers(Headers) -> end end. -response_io_from_headers(Version, Headers) -> +response_io_from_headers(_, 204, _) -> + head; +response_io_from_headers(Version, Status, Headers) -> case lists:keyfind(<<"content-length">>, 1, Headers) of {_, <<"0">>} -> head; -- cgit v1.2.3