Просмотр исходного кода

Remove the 'HEAD' chunked_reply/3 clause

From the RFC:
  The HEAD method is identical to GET except that the server MUST NOT
  return a message-body in the response. The metainformation contained
  in the HTTP headers in response to a HEAD request SHOULD be identical
  to the information sent in response to a GET request.
Loïc Hoguin 13 лет назад
Родитель
Сommit
c2be0f2073
2 измененных файлов с 2 добавлено и 8 удалено
  1. 2 0
      src/cowboy_http_protocol.erl
  2. 0 8
      src/cowboy_http_req.erl

+ 2 - 0
src/cowboy_http_protocol.erl

@@ -284,6 +284,8 @@ ensure_response(Req=#http_req{resp_state=waiting}) ->
 	_ = cowboy_http_req:reply(204, [], [], Req),
 	ok;
 %% Close the chunked reply.
+ensure_response(#http_req{method='HEAD', resp_state=chunks}) ->
+	close;
 ensure_response(#http_req{socket=Socket, transport=Transport,
 		resp_state=chunks}) ->
 	Transport:send(Socket, <<"0\r\n\r\n">>),

+ 0 - 8
src/cowboy_http_req.erl

@@ -336,14 +336,6 @@ reply(Code, Headers, Body, Req=#http_req{socket=Socket,
 -spec chunked_reply(http_status(), http_headers(), #http_req{})
 	-> {ok, #http_req{}}.
 chunked_reply(Code, Headers, Req=#http_req{socket=Socket, transport=Transport,
-		method='HEAD', resp_state=waiting}) ->
-	Head = response_head(Code, Headers, [
-		{<<"Date">>, cowboy_clock:rfc1123()},
-		{<<"Server">>, <<"Cowboy">>}
-	]),
-	Transport:send(Socket, Head),
-	{ok, Req#http_req{resp_state=done}};
-chunked_reply(Code, Headers, Req=#http_req{socket=Socket, transport=Transport,
 		resp_state=waiting}) ->
 	Head = response_head(Code, Headers, [
 		{<<"Connection">>, <<"close">>},