diff -r 2b6cdff92b09 -r 99b749da5149 includes/http.php --- a/includes/http.php Tue Apr 06 15:54:45 2010 -0400 +++ b/includes/http.php Tue Apr 06 15:55:21 2010 -0400 @@ -370,10 +370,8 @@ $newline = "\r\n"; if ( $this->debug ) + { echo '

Connection opened. Writing main request to socket. Raw socket data follows.

';
-		
-		if ( $this->debug )
-		{
 			echo '
'; echo '

' . __CLASS__ . ': Sending request

Request parameters:

'; echo "

Headers:

$headers
"; @@ -386,7 +384,7 @@ $portline = ( $this->port == 80 ) ? '' : ":$this->port"; $this->_fputs($connection, "{$this->method} {$this->uri}{$get} HTTP/1.1{$newline}"); - $this->_fputs($connection, "Host: {$this->host}$portline{$newline}"); + $this->_fputs($connection, "Host: {$this->host}{$portline}{$newline}"); $this->_fputs($connection, $headers); $this->_fputs($connection, $cookies); @@ -528,7 +526,17 @@ { echo "Pulling response using fread(), size $size\n"; } - $this->response .= fread($this->socket, $size); + $basesize = strlen($this->response); + while ( strlen($this->response) - $basesize < $size ) + { + $remaining_bytes = $size - (strlen($this->response) - $basesize); + $this->response .= fread($this->socket, $remaining_bytes); + if ( $this->debug ) + { + $remaining_bytes = $size - (strlen($this->response) - $basesize); + echo "
Received " . (strlen($this->response) - $basesize) . " of $size bytes ($remaining_bytes remaining)...\n"; + } + } } else {