[PATCH 11 of 12] hgweb: use chunked encoding in responses
Maxim Dounin
mdounin at mdounin.ru
Sat Jan 12 13:19:20 CST 2013
Hello!
On Sat, Jan 12, 2013 at 12:32:55AM +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski at unity3d.com>
> # Date 1357947109 -3600
> # Node ID d4104616205bc3d9fa665a6cae85bc702774987c
> # Parent d085fef69932009da56e66d46b75da5c885cf91a
> hgweb: use chunked encoding in responses
>
> hgweb closed the established http connections when the content length was
> unknown. That caused extra connections to be created and thus some extra
> connection overhead, extra ssl warnings and extra authentication steps.
>
> By using 'Transfer-Encoding: chunked' when streaming a response with
> unknown length it is possible to keep connections alive.
>
> Responses where the content body (and thus its length) is unknown when sending
> the header will use chunked encoding. The iterator corresponding to this
> request must pass through .processiter() to make sure it gets the necessary
> chunkencoding.
>
> The changed hash in test-clone-cgi.t is caused by the chunked headers and
> encoding.
[...]
Please note that:
1) "Transfer-Encoding: chunked" isn't allowed when talking to
HTTP/1.0 clients. Quote from RFC 2616,
http://tools.ietf.org/html/rfc2616#section-3.6:
... A server MUST NOT send transfer-codings to an HTTP/1.0
client.
2) It's probably bad idea to use "Transfer-Encoding" while working
via CGI and derived protocols like FastCGI. Quote from RFC 3875,
http://tools.ietf.org/html/rfc3875#section-6.3.4:
The script MUST NOT return any header fields that relate to
client-side communication issues and could affect the server's
ability to send the response to the client.
Overall, I don't think you should try to put "Transfer-Encoding:
chunked" logic into hgweb. It should be server's job to do the
right thing and keep the connection alive if possible.
--
Maxim Dounin
More information about the Mercurial-devel
mailing list