php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47759 file_get_contents does not decode chunk encoded data
Submitted: 2009-03-24 13:39 UTC Modified: 2009-03-25 12:18 UTC
From: marques at displague dot com Assigned:
Status: Not a bug Package: HTTP related
PHP Version: 5.2.9 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marques at displague dot com
New email:
PHP Version: OS:

 

 [2009-03-24 13:39 UTC] marques at displague dot com
Description:
------------
file_get_contents() does not decode HTTP content sent with "Transfer-Encoding: chunked".  This is probably also true for fopen() and other HTTP stream handlers in PHP.

RFC2616 section 3.6.1:
   All HTTP/1.1 applications MUST be able to receive and decode the
   "chunked" transfer-coding, and MUST ignore chunk-extension extensions
   they do not understand.



Reproduce code:
---------------
echo file_get_contents('somechunkedurl.html');

Expected result:
----------------
This is the data in the first chunk and this is the second one


Actual result:
--------------
23
This is the data in the first chunk

1A
and this is the second one

0


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-24 23:50 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 [2009-03-25 12:18 UTC] marques at displague dot com
Chunk encoding is a requirement of HTTP/1.1 clients.  If file_get_contents is going to claim to be able to fetch http streams, then it needs to come forward about its limitation of HTTP/1.0 on it's manual page. This can only be inferred by reading the HTTP wrapper manual.  In this way I have reported a documentation bug.

Moreover, the HTTP wrapper should be made to be HTTP/1.1 capable.  Although, in this century, lack of HTTP/1.1 support in an HTTP client is fairly crippling, this bug can be considered a feature request.

Feel free to change the summary to more appropriately reflect one of these two bugs.  The end result however is the same, file_get_contents does not decode chunk encoded data.

http://php.net/file_get_contents
http://us3.php.net/manual/en/wrappers.http.php
 [2011-12-30 13:42 UTC] alpegalpeg at gmail dot com
There is a PECL module and also pure php workaround:
http://www.php.net/manual/en/function.http-chunked-decode.php#89786
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC