title: I need to go through a proxy, (from a running fsockopen code that gets the size from a remote video file)
body: <p>I've a PHP running code that ask the file size of a remote mp4 file, thanks to a fsockopen function and HEAD command.</p>
  
  <p>Now, i need to move this code to other server behind a proxy, which is the best approach to go through that new proxy, and continue using fsockopen? I'm really stuck. I can't tunnel or handle two sockets.</p>
  
  <p>Any ideas? thanks for your help and time.</p>
  
  <pre><code>private function filesize_remote($remotefile, $timeout=10) {
         $size = false;
         $url = parse_url($remotefile);
  
         if ($fp = @fsockopen($url['host'], ($url['port'] ? $url['port'] : 80), $errno, $errstr, $timeout)) {
            fwrite($fp, 'HEAD '.@$url['path'].@$url['query'].' HTTP/1.0'."\r\n".'Host: '.@$url['host']."\r\n\r\n");
            while (!feof($fp)) {
               $headerline = fgets($fp, 4096);
               if (preg_match('/^Content-Length: (.*)/', $headerline, $matches)) {
                  $size = intval($matches[1]);
                  break;
               }
            }
            fclose ($fp);
         }
  
         return $size;  
      } 
  </code></pre>