[EDIT: I'm trying to make an HTTP request from a PHP script to an external server.]
I'm using Example 1 from http://php.net/manual/en/function.fsockopen.php modified to:
<?php
$fp = fsockopen("m2.exosite.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET /api:v1/stack/alias?1 HTTP/1.1\r\n";
$out .= "Host: m2.exosite.com\r\n";
$out .= "X-Exosite-CIK: a32c85ba9dda45823be416246cf8b433baa068d7\r\n";
$out .= "Accept: application/x-www-form-urlencoded; charset=utf-8\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
When I run this I see at the terminal:
HTTP/1.1 200 OK
Date: Wed, 07 May 2014 13:51:40 GMT
Content-Length: 4
Connection: keep-alive
Server: nginx
<60 second pause>
1=37
However, when I watch it in wireshark, I see one HTTP packet that includes the body 1=37 get sent at the same time I see the headers in my terminal. But I only see the body in my terminal when the server closes the socket (just a tcp [FIN, ACK], no data is sent). I assume that means that the body of the response is stuck in PHP somewhere. Is there some that I need to do to get the body to be read out?