#47684 [Opn-Csd]: file_get_contents Content-Length problem

2009-04-05 Thread r-ser at yandex dot ru
 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] lbarn...@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] j...@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=47684edit=1



#47684 [Fbk-Opn]: file_get_contents Content-Length problem

2009-03-18 Thread r-ser at yandex dot ru
 ID:   47684
 User updated by:  r-ser at yandex dot ru
 Reported By:  r-ser at yandex dot ru
-Status:   Feedback
+Status:   Open
 Bug Type: HTTP related
 Operating System: Linux 2.6.26
 PHP Version:  5.2.9
 New Comment:

/* this message is to change status.. =) */


Previous Comments:


[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] j...@php.net

Why are you not passing the content-length in there..? I mean, isn't
that the obvious error..? :)



[2009-03-17 00:15:55] r-ser at yandex dot ru

Description:

When use file_get_contents + stream_context_create to post file to web
server and the page in web server return redirect to another page
(location field in answer), then file_get_contents requested
redirected page with POST header without Content-Length: field in
request and server response HTTP/1.0 411 Length Required.
I think, it's two ways to fix problem
1) 'method' must be change to GET in requests to redirect pages.
2) Add 'Content-Length: 0' to next POST redirect requests

Reproduce code:
---
$argv[1] = image.jpg;
$boundary = AaB03x1234567890;
$type = mime_content_type($argv[1]);
$data = --$boundary\r\nContent-Disposition: form-data;
name=\fileupload\; filename=\.basename($argv[1]).\
Content-Type: .$type. \r\nContent-Transfer-Encoding:
binary\r\n\r\n.file_get_contents($argv[1]).\r\n--$boundary--;
$header = Content-type: multipart/form-data, boundary=$boundary;
$context  = stream_context_create(array('http' =
array('method'='POST', 'header'= $header, 'content' = $data)));
$result = file_get_contents('http://load.imageshack.us', false,
$context);
echo $result;

Expected result:

failed to open stream: HTTP request failed! HTTP/1.0 411 Length
Required

Actual result:
--
Normal redirected page





-- 
Edit this bug report at http://bugs.php.net/?id=47684edit=1



#47684 [Com]: file_get_contents Content-Length problem

2009-03-17 Thread r-ser at yandex dot ru
 ID:   47684
 Comment by:   r-ser at yandex dot ru
 Reported By:  r-ser at yandex dot ru
 Status:   Feedback
 Bug Type: HTTP related
 Operating System: Linux 2.6.26
 PHP Version:  5.2.9
 New Comment:

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 */


Previous Comments:


[2009-03-17 11:00:15] j...@php.net

Why are you not passing the content-length in there..? I mean, isn't
that the obvious error..? :)



[2009-03-17 00:15:55] r-ser at yandex dot ru

Description:

When use file_get_contents + stream_context_create to post file to web
server and the page in web server return redirect to another page
(location field in answer), then file_get_contents requested
redirected page with POST header without Content-Length: field in
request and server response HTTP/1.0 411 Length Required.
I think, it's two ways to fix problem
1) 'method' must be change to GET in requests to redirect pages.
2) Add 'Content-Length: 0' to next POST redirect requests

Reproduce code:
---
$argv[1] = image.jpg;
$boundary = AaB03x1234567890;
$type = mime_content_type($argv[1]);
$data = --$boundary\r\nContent-Disposition: form-data;
name=\fileupload\; filename=\.basename($argv[1]).\
Content-Type: .$type. \r\nContent-Transfer-Encoding:
binary\r\n\r\n.file_get_contents($argv[1]).\r\n--$boundary--;
$header = Content-type: multipart/form-data, boundary=$boundary;
$context  = stream_context_create(array('http' =
array('method'='POST', 'header'= $header, 'content' = $data)));
$result = file_get_contents('http://load.imageshack.us', false,
$context);
echo $result;

Expected result:

failed to open stream: HTTP request failed! HTTP/1.0 411 Length
Required

Actual result:
--
Normal redirected page





-- 
Edit this bug report at http://bugs.php.net/?id=47684edit=1



#47684 [Com]: file_get_contents Content-Length problem

2009-03-17 Thread r-ser at yandex dot ru
 ID:   47684
 Comment by:   r-ser at yandex dot ru
 Reported By:  r-ser at yandex dot ru
 Status:   Feedback
 Bug Type: HTTP related
 Operating System: Linux 2.6.26
 PHP Version:  5.2.9
 New Comment:

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.


Previous Comments:


[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] j...@php.net

Why are you not passing the content-length in there..? I mean, isn't
that the obvious error..? :)



[2009-03-17 00:15:55] r-ser at yandex dot ru

Description:

When use file_get_contents + stream_context_create to post file to web
server and the page in web server return redirect to another page
(location field in answer), then file_get_contents requested
redirected page with POST header without Content-Length: field in
request and server response HTTP/1.0 411 Length Required.
I think, it's two ways to fix problem
1) 'method' must be change to GET in requests to redirect pages.
2) Add 'Content-Length: 0' to next POST redirect requests

Reproduce code:
---
$argv[1] = image.jpg;
$boundary = AaB03x1234567890;
$type = mime_content_type($argv[1]);
$data = --$boundary\r\nContent-Disposition: form-data;
name=\fileupload\; filename=\.basename($argv[1]).\
Content-Type: .$type. \r\nContent-Transfer-Encoding:
binary\r\n\r\n.file_get_contents($argv[1]).\r\n--$boundary--;
$header = Content-type: multipart/form-data, boundary=$boundary;
$context  = stream_context_create(array('http' =
array('method'='POST', 'header'= $header, 'content' = $data)));
$result = file_get_contents('http://load.imageshack.us', false,
$context);
echo $result;

Expected result:

failed to open stream: HTTP request failed! HTTP/1.0 411 Length
Required

Actual result:
--
Normal redirected page





-- 
Edit this bug report at http://bugs.php.net/?id=47684edit=1



#47684 [NEW]: file_get_contents Content-Length problem

2009-03-16 Thread r-ser at yandex dot ru
From: r-ser at yandex dot ru
Operating system: Linux 2.6.26
PHP version:  5.2.9
PHP Bug Type: HTTP related
Bug description:  file_get_contents Content-Length problem

Description:

When use file_get_contents + stream_context_create to post file to web
server and the page in web server return redirect to another page
(location field in answer), then file_get_contents requested redirected
page with POST header without Content-Length: field in request and server
response HTTP/1.0 411 Length Required.
I think, it's two ways to fix problem
1) 'method' must be change to GET in requests to redirect pages.
2) Add 'Content-Length: 0' to next POST redirect requests

Reproduce code:
---
$argv[1] = image.jpg;
$boundary = AaB03x1234567890;
$type = mime_content_type($argv[1]);
$data = --$boundary\r\nContent-Disposition: form-data;
name=\fileupload\; filename=\.basename($argv[1]).\
Content-Type: .$type. \r\nContent-Transfer-Encoding:
binary\r\n\r\n.file_get_contents($argv[1]).\r\n--$boundary--;
$header = Content-type: multipart/form-data, boundary=$boundary;
$context  = stream_context_create(array('http' = array('method'='POST',
'header'= $header, 'content' = $data)));
$result = file_get_contents('http://load.imageshack.us', false,
$context);
echo $result;

Expected result:

failed to open stream: HTTP request failed! HTTP/1.0 411 Length Required

Actual result:
--
Normal redirected page

-- 
Edit bug report at http://bugs.php.net/?id=47684edit=1
-- 
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47684r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47684r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47684r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47684r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47684r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47684r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=47684r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=47684r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=47684r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=47684r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=47684r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=47684r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=47684r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47684r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=47684r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=47684r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=47684r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=47684r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=47684r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=47684r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=47684r=mysqlcfg