couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: svn commit: r808632 - /couchdb/trunk/src/couchdb/couch_httpd.erl
Date Thu, 27 Aug 2009 21:20:00 GMT
Does this mean that HEAD requests for views don't return a
Content-Length header? And is that important?

Paul Davis

On Thu, Aug 27, 2009 at 5:16 PM, <damien@apache.org> wrote:
> Author: damien
> Date: Thu Aug 27 21:16:08 2009
> New Revision: 808632
>
> URL: http://svn.apache.org/viewvc?rev=808632&view=rev
> Log:
> Fix for problem where HEAD requests that would have a chunked responses would send the
chunked respone anyway. Also, we now avoid processing the request, and instead abort it as
soon as the header is sent.
>
> Modified:
>    couchdb/trunk/src/couchdb/couch_httpd.erl
>
> Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
> URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=808632&r1=808631&r2=808632&view=diff
> ==============================================================================
> --- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
> +++ couchdb/trunk/src/couchdb/couch_httpd.erl Thu Aug 27 21:16:08 2009
> @@ -153,7 +153,6 @@
>     end,
>
>     increment_method_stats(Method1),
> -
>     % alias HEAD to GET as mochiweb takes care of stripping the body
>     Method = case Method1 of
>         'HEAD' -> 'GET';
> @@ -180,6 +179,8 @@
>             Response
>         end
>     catch
> +        throw:{http_head_abort, Resp0} ->
> +            {ok, Resp0};
>         throw:Error ->
>             ?LOG_DEBUG("Minor error in HTTP request: ~p",[Error]),
>             ?LOG_DEBUG("Stacktrace: ~p",[erlang:get_stacktrace()]),
> @@ -360,7 +361,12 @@
>
>  start_response_length(#httpd{mochi_req=MochiReq}=Req, Code, Headers, Length) ->
>     couch_stats_collector:increment({httpd_status_codes, Code}),
> -    {ok, MochiReq:start_response_length({Code, Headers ++ server_header() ++ couch_httpd_auth:cookie_auth_header(Req,
Headers), Length})}.
> +    Resp = MochiReq:start_response_length({Code, Headers ++ server_header() ++ couch_httpd_auth:cookie_auth_header(Req,
Headers), Length}),
> +    case MochiReq:get(method) of
> +    'HEAD' -> throw({http_head_abort, Resp});
> +    _ -> ok
> +    end,
> +    {ok, Resp}.
>
>  send(Resp, Data) ->
>     Resp:send(Data),
> @@ -368,7 +374,12 @@
>
>  start_chunked_response(#httpd{mochi_req=MochiReq}=Req, Code, Headers) ->
>     couch_stats_collector:increment({httpd_status_codes, Code}),
> -    {ok, MochiReq:respond({Code, Headers ++ server_header() ++ couch_httpd_auth:cookie_auth_header(Req,
Headers), chunked})}.
> +    Resp = MochiReq:respond({Code, Headers ++ server_header() ++ couch_httpd_auth:cookie_auth_header(Req,
Headers), chunked}),
> +    case MochiReq:get(method) of
> +    'HEAD' -> throw({http_head_abort, Resp});
> +    _ -> ok
> +    end,
> +    {ok, Resp}.
>
>  send_chunk(Resp, Data) ->
>     Resp:write_chunk(Data),
>
>
>

Mime
View raw message