From:             
Operating system: linux
PHP version:      5.3.10
Package:          HTTP related
Bug Type:         Bug
Bug description:content-type must appear at the end of headers for 201 Location 
to work in http

Description:
------------
Line 445 of http_fopen_wrapper.c
only works of the content-type is at the end of a list of header fields in
the 
context. It fails if it is in the middle, or the beginning.

memmove(tmp, tmp + (s2 + 1 - tmp_c), tmp_c + l - 1 - s2);

To see the problem watch the HTTP stream in something like WireShark.


Test script:
---------------
<?php
$http = array(
   'header' =>
      null
      ."AnyHeader: 1\r\n"
      // BUG on line 445 of http_fopen_wrapper.c of PHP: content_type
cannot be in the middle of headers.
      ."Content-type: anythingyouwanthere\r\n"
      ."SomeOtherHeader: 2\r\n"
);
/*
PHP incorrectly sends across when following the "Location":
GET /services/storm/lead HTTP/1.0
Host: storm
SomeOtherHeader: 2ent-type: anythingyouwanthere
SomeOtherHeader: 2
 */
$http['method'] = 'POST';
$options = array('http' => $http);
$context = stream_context_create($options);
$result =
file_get_contents('http://some/url/that/resturns/201/and/has/a/Location/in/the/header',
false, $context);


Expected result:
----------------
GET /services/storm/lead HTTP/1.0
Host: storm
AnyHeader: 1
SomeOtherHeader: 2

Actual result:
--------------
GET /services/storm/lead HTTP/1.0
Host: storm
SomeOtherHeader: 2ent-type: anythingyouwanthere
SomeOtherHeader: 2

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

Reply via email to