Re: Re: Slow file download

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brian Dunning wrote:
IIS, Windows PHP 5.2.6, and unfortunately the downloads are https.

On Dec 2, 2008, at 12:32 PM, Nathan Rixham wrote:

what's the server running? iis/apache, win/linux version of php (as accurate as you can) oh and via http or https/ssl?

now I may be wrong but I'm rather sure that IIS has a bug where it doesn't close http connections properly, thus you're connection isn't closing until it times out (even though download finished ages ago).

There's some notes on the php site about it but can't seem to spot them at the minute..

if memory serves me correctly lowering that timeout to something like 5 seconds will do the trick / or using a manual conenction like..

<?php
$protocol = 'ssl://';
$server = 'yoursite.com';
$port = 443; // ssl port?
$context = // your context here
$rawHttpResponse = '';

$rawHttpRequest = "GET /file.ext HTTP/1.1\r\nHost: " . $server . "\r\n";
$rawHttpRequest .= "Connection: Close\r\n\r\n';

if( $fp = stream_socket_client($protocol.$server.':'.$port], $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $context) ) {
  fwrite($fp, $rawHttpRequest);
  stream_set_timeout($fp, 10);
  while (!feof($fp)) {
    $a = stream_get_meta_data($fp);
    if($a['timed_out']) {
      return false; //timed out
    }
    $rawHttpResponse .= fgets($fp, 2);
  }
  fclose($fp);
}
echo $rawHttpResponse . PHP_EOL;
?>

totally untested :p

best of luck!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux