#47684 [Opn->Csd]: file_get_contents "Content-Length" problem
| From: | r-ser at yandex dot ru | Date: | Sun, 05 Apr 2009 14:23:49 +0000 |
| Subject: | #47684 [Opn->Csd]: file_get_contents "Content-Length" problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-135551@lists.php.net to get a copy of this message | ||
ID: 47684
User updated by: r-ser at yandex dot ru
Reported By: r-ser at yandex dot ru
-Status: Open
+Status: Closed
Bug Type: HTTP related
Operating System: Linux 2.6.26
PHP Version: 5.2.9
New Comment:
Yes,in PHP 5.3 all works fine.
Previous Comments:
------------------------------------------------------------------------
[2009-04-04 16:35:41] lbarnaud@php.net
This problem had been fixed in PHP 5.3 (#45540), could you please check
with PHP 5.3 ?
------------------------------------------------------------------------
[2009-03-18 10:59:28] r-ser at yandex dot ru
/* this message is to change status.. =) */
------------------------------------------------------------------------
[2009-03-17 19:55:06] r-ser at yandex dot ru
Add string
php_stream_context_set_option(context, "http", "method", (zval *)
"GET");
Before
stream = php_stream_url_wrap_http_ex(wrapper, new_path, mode, options,
opened_path, context, --redirect_max, 0 STREAMS_CC TSRMLS_CC);
In ext/standard/http_fopen_wrapper.c
Solved problem.
------------------------------------------------------------------------
[2009-03-17 16:13:21] r-ser at yandex dot ru
I can write this code as
$header = "Content-type: multipart/form-data,
boundary=$boundary\r\nContent-Length: ".strlen($data)."\r\n";
But nothing is changed.
Becouse error is in _second_ request.
cat test.php
------------
<?php
$context = stream_context_create(array('http' =>
array('method'=>'POST', 'header'=> 'Content-Length:
0', 'content' =>
'')));
echo file_get_contents('http://localhost/1.php', false, $context);
?>
------------
cat 1.php
------------
<?php
header("Location: 2.php");
?>
------------
cat 2.php
------------
<?
echo "Method: ".$_SERVER['REQUEST_METHOD']."\n";
$headers = getallheaders();
foreach ($headers as $header => $value) echo "$header: $value\n";
?>
------------
Note: 1.php and 2.php are located in root of webserver
if change http://localhost/1.php to http://localhost/2.php you can see
differents headers..
This works with Apache web server.
But not work with some elses, like lighttpd/1.5.0 /* like in example in
first message */
------------------------------------------------------------------------
[2009-03-17 11:00:15] jani@php.net
Why are you not passing the content-length in there..? I mean, isn't
that the obvious error..? :)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/47684
--
Edit this bug report at http://bugs.php.net/?id=47684&edit=1