Re: Support for "Transfer-Encoding: chunked" in http stream wrapper
| From: | Dmitry Stogov | Date: | Wed, 15 Apr 2009 11:51:10 +0000 |
| Subject: | Re: Support for "Transfer-Encoding: chunked" in http stream wrapper | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-43711@lists.php.net to get a copy of this message | ||
Hi,
Thanks for comments.
The updated patch fixes RFC incompatibilities. It just ignores
extensions and trailer.
The patch also exports "chunked" filter into user space so now it can be
used with any streams (see test in the patch).
In case user opens http stream and server responds with
"Transfer-Encoding: chunked" header, php applies chunked filter
automatically and doesn't bypass "Transfer-Encoding" header to user.
The automatic decoding may be disabled using stream_context.
stream_context_create(array("http"=>array("auto_decode"=>0)));
Any objections against applying it into 5.3?
I think it's very easy to add automatic decompression of HTTP responses
with HTTP headers "Content-Encoding: gzip" (and others) using similar
patch (except for filters are already implemented and the patch will
need to update only http_fopen_wrapper.c).
Thanks. Dmitry.
Sara Golemon wrote:
>> The attached patch implements automatic decoding of chunked
>> transfer-encoding.
>>
>> Any objections against committing the patch into PHP_5_3?
>>
> I didn't have objections when I offered this filter several years ago,
> and I still don't. I do recall Andi (or perhaps it was someone else)
> saying it was adding unnecessary complexity to the http wrapper and
> such things should be left for cURL though, and this is why it didn't
> go into 5.1
>
>> Maybe someone has ideas about patch improvements?
>>
> I'd add a context option to disable automatic application of the
> filter, and register the filter with the streams layer so that it can
> be applied manually. (And of course, I'd second Stas' comment wrt
> chunk-header length)
>
> The issue wrt 1.0 versus 1.1 is fairly moot. If the caller doesn't
> override the version then the server won't send chunked encoding.
> They are capable of doing so however, and they may already be doing it
> (e.g. for a streaming client). So the concern about potential BC
> breakage for apps still exists, it's just less severe (since I doubt
> many apps *are* explicitly setting the version to 1.1)
>
> -Sara