equal
deleted
inserted
replaced
368 function _write_request(&$connection, &$headers, &$cookies, &$get, &$post) |
368 function _write_request(&$connection, &$headers, &$cookies, &$get, &$post) |
369 { |
369 { |
370 $newline = "\r\n"; |
370 $newline = "\r\n"; |
371 |
371 |
372 if ( $this->debug ) |
372 if ( $this->debug ) |
|
373 { |
373 echo '<p>Connection opened. Writing main request to socket. Raw socket data follows.</p><pre>'; |
374 echo '<p>Connection opened. Writing main request to socket. Raw socket data follows.</p><pre>'; |
374 |
|
375 if ( $this->debug ) |
|
376 { |
|
377 echo '<hr /><div style="white-space: nowrap;">'; |
375 echo '<hr /><div style="white-space: nowrap;">'; |
378 echo '<p><b>' . __CLASS__ . ': Sending request</b></p><p>Request parameters:</p>'; |
376 echo '<p><b>' . __CLASS__ . ': Sending request</b></p><p>Request parameters:</p>'; |
379 echo "<p><b>Headers:</b></p><pre>$headers</pre>"; |
377 echo "<p><b>Headers:</b></p><pre>$headers</pre>"; |
380 echo "<p><b>Cookies:</b> $cookies</p>"; |
378 echo "<p><b>Cookies:</b> $cookies</p>"; |
381 echo "<p><b>GET URI:</b> " . htmlspecialchars($this->uri . $get) . "</p>"; |
379 echo "<p><b>GET URI:</b> " . htmlspecialchars($this->uri . $get) . "</p>"; |
384 } |
382 } |
385 |
383 |
386 $portline = ( $this->port == 80 ) ? '' : ":$this->port"; |
384 $portline = ( $this->port == 80 ) ? '' : ":$this->port"; |
387 |
385 |
388 $this->_fputs($connection, "{$this->method} {$this->uri}{$get} HTTP/1.1{$newline}"); |
386 $this->_fputs($connection, "{$this->method} {$this->uri}{$get} HTTP/1.1{$newline}"); |
389 $this->_fputs($connection, "Host: {$this->host}$portline{$newline}"); |
387 $this->_fputs($connection, "Host: {$this->host}{$portline}{$newline}"); |
390 $this->_fputs($connection, $headers); |
388 $this->_fputs($connection, $headers); |
391 $this->_fputs($connection, $cookies); |
389 $this->_fputs($connection, $cookies); |
392 |
390 |
393 if ( $this->method == 'POST' ) |
391 if ( $this->method == 'POST' ) |
394 { |
392 { |
526 $size = intval($match[1]); |
524 $size = intval($match[1]); |
527 if ( $this->debug ) |
525 if ( $this->debug ) |
528 { |
526 { |
529 echo "Pulling response using fread(), size $size\n"; |
527 echo "Pulling response using fread(), size $size\n"; |
530 } |
528 } |
531 $this->response .= fread($this->socket, $size); |
529 $basesize = strlen($this->response); |
|
530 while ( strlen($this->response) - $basesize < $size ) |
|
531 { |
|
532 $remaining_bytes = $size - (strlen($this->response) - $basesize); |
|
533 $this->response .= fread($this->socket, $remaining_bytes); |
|
534 if ( $this->debug ) |
|
535 { |
|
536 $remaining_bytes = $size - (strlen($this->response) - $basesize); |
|
537 echo "<br />Received " . (strlen($this->response) - $basesize) . " of $size bytes ($remaining_bytes remaining)...\n"; |
|
538 } |
|
539 } |
532 } |
540 } |
533 else |
541 else |
534 { |
542 { |
535 if ( $this->debug ) |
543 if ( $this->debug ) |
536 echo "Pulling response using chunked handler\n"; |
544 echo "Pulling response using chunked handler\n"; |