I'm attempting a GET request and I'm receiving a timeout. Strange thing is I've got a DEV url and a PROD url. And only the DEV url is working. I'd rather not list the urls here since these are live urls. Any idea why one url might be working the other isn't. The client claims there is no difference b/t the servers. I believe their server is IIS.
Many thanks. The code is below for reference.
Code: Select all
$url = preg_replace("@^https://@i", "", $url); //https
$url = preg_replace("@^http://@i", "", $url); //or http
$host = substr($url, 0, strpos($url, "/"));
$uri = strstr($url, "/");
//BUILD POST BODY
$reqbody = "";
foreach($datastream as $key => $val) {
if (!empty($reqbody))
$reqbody.= "&";
$reqbody.= $key."=".urlencode($val);
}
//BUILD POST HEADER
$contentlength = strlen($reqbody);
//$debug = true;
$debug = false;
if (!$debug) {
$reqheader = "GET $uri HTTP/1.0\r\n".
"Host: $host\r\n". "User-Agent: PostIt\r\n".
"Content-Type: text/xml\r\n".
"Content-Length: $contentlength\r\n\r\n".
"$reqbody\r\n";
} else {
$reqheader = "GET $uri?" . $reqbody . " HTTP/1.0\r\n".
"Host: $host\r\n". "User-Agent: PostIt\r\n".
"Content-Type: text/plain\r\n\r\n";
}
//Connect to the Datasource
$socket = fsockopen($host, 80, $errno, $errstr);
if (!$socket) {
$err = trigger_error("ERROR", E_USER_WARNING);
$result["errno"] = $errno;
$result["errstr"] = $errstr;
writeERRtoDB($errno);
return $result;
}
fputs($socket, $reqheader);
while (!feof($socket)) {
$result[] = fgets($socket, 4096);
}
fclose($socket);
Print_r ($result);