Why is this fsockopen
so slow compared to the same request from a browser?
php fsockopen: 0.254
secs
browser: 0.070
secs
fsockopen request
$time = microtime(true);
if($fp = fsockopen('ssl://domain.com', 443, $errno, $errstr, 20)){
echo "\n".(microtime(true) - $time);
$this->request = 'POST '.$path.' HTTP/1.1'.$crlf
.'Host: '.$this->host.$crlf
.'Content-Type: application/x-www-form-urlencoded'.$crlf
.'Content-Length: '.$content_length.$crlf
.'Connection: Close'.$crlf.$crlf
.$body;
fwrite($fp, $this->request);
while($line = fgets($fp)){
if($line !== false){
$this->response .= $line;
}
}
fclose($fp);
}
echo "\n".(microtime(true) - $time);
fsockopen results
0.18865990638733
0.25424790382385