stream_context_create + file_get_content doesn't retrieve full file

Bug #650779 reported by abma on 2010-09-29
This bug affects 2 people
Affects Status Importance Assigned to Milestone
php5 (Ubuntu)
Pratik Soni

Bug Description

Binary package hint: php5

when running the example script, the xml-request is simple cut of at the end, it ends with:


but server-side is ok, with the curl-wrapper the request succeds.
look answer.txt for the result (yes, it is complete!)

php --version
PHP 5.3.2-1ubuntu4.5 with Suhosin-Patch (cli) (built: Sep 17 2010 13:49:46)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid

abma (abma) wrote :
abma (abma) wrote :
description: updated
description: updated
description: updated
Clint Byrum (clint-fewbar) wrote :

I tried this on the latest version of PHP in Maverick (5.3.3-1ubuntu9), and I see the same truncation issue.

Also I tried doing the POST with the curl_xxx functions and the XML was complete.

Marking Triaged, as there is definitely enough here to get started on a fix.

Setting Importance to High, as this could potentially corrupt data and gives no indication of a problem other than incomplete data transfer.

Changed in php5 (Ubuntu):
status: New → Triaged
importance: Undecided → High
Clint Byrum (clint-fewbar) wrote :

Oh, and thanks, Matthias, for taking the time to file this bug report!

Clint Byrum (clint-fewbar) wrote :

Changing status to Confirmed, this needs to be forwarded

Changed in php5 (Ubuntu):
status: Triaged → Confirmed
Christian Weiske (cweiske) wrote :

This actually happens with a much smaller test script, as soon as you use POST together with "content" in the context options.

$opts = array('http' => array('method' => 'POST', 'content' => 'foo'));
$context = stream_context_create($opts);
$result = file_get_contents('http://localhost/poster.php', false, $context);

PHP Warning: file_get_contents(http://localhost:4436/ResourceAll): failed to open stream: HTTP request failed!

When you remove the content key, all is fine.

abma (abma) wrote :

is this the upstream bug ?

Pratik Soni (php-techie) on 2014-12-06
Changed in php5 (Ubuntu):
assignee: nobody → Pratik Soni (php-techie)
Pratik Soni (php-techie) on 2014-12-06
Changed in php5 (Ubuntu):
status: Confirmed → In Progress
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.