From:             
Operating system: Red Hat Linux
PHP version:      5.2.13
Package:          Network related
Bug Type:         Bug
Bug description:fsockopen+fread behaves differently with port 443 vs. port 80

Description:
------------
If I open a network connection with fsockopen on port 80, then read the
first 

chunk of the response with fread, I receive the response headers plus
enough of 

the response body to fulfill the read length that I requested.



However, if I do the same thing over port 443, I receive only the response
headers 

in my initial fread command, regardless of their length. I don't receive
any of 

the response body until I call fread again.



The script below demonstrates this. If you run it as shown, you will see
the 

header plus part of the body as response 1, and a continuation of the body
as 

response 2. But if you change $connection_port to 443, you will see only
the 

header as response 1, with the body starting at response 2.



I repeated this issue on one server running PHP 5.2.13 and another running
5.3.0.

Test script:
---------------
<?php

        $connection_port = 80;



        $source_domain = "www.msgen.com";

        $source_path = "/assembled/home.html";



        $source_host = ($connection_port == 443) ? "ssl://$source_domain" :
$source_domain ;

        $request = "GET /$source_path HTTP/1.0\nHost: 
$source_domain\nConnection:
close\n\n";



        $socket = fsockopen($source_host, $connection_port, $error_number,
$error_string);

        fputs($socket, $request);



        $response_1 = fread($socket, 4096);

        $response_2 = fread($socket, 4096);

        

        print "response 1:<br />\n".htmlentities($response_1);

        print "<br /><br />\n";

        print "response 2:<br />\n".htmlentities($response_2);

?>

Expected result:
----------------
I would expect fread to return the same results regardless of the port used
for 

fsockopen.

Actual result:
--------------
The first instance of fread stops at the end of the headers when using port
443.

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

Reply via email to