static function fopen_request($url, $r) { $arrURL = parse_url($url); if (!isset($arrURL['scheme'])) { $arrURL['scheme'] = 'http'; } if ($arrURL['scheme'] != 'http' && $arrURL['scheme'] != 'https') { $url = preg_replace('|^' . preg_quote($arrURL['scheme'], '|') . '|', 'http', $url); } $handle = @fopen($url, 'r'); if (!$handle) { return false; } gpRemoteGet::stream_timeout($handle, $r['timeout']); $strResponse = ''; while (!feof($handle)) { $strResponse .= fread($handle, 4096); } $theHeaders = gpRemoteGet::StreamHeaders($handle); if ($theHeaders === false) { //$http_response_header is a PHP reserved variable which is set in the current-scope when using the HTTP Wrapper //see http://php.oregonstate.edu/manual/en/reserved.variables.httpresponseheader.php $theHeaders = $http_response_header; } fclose($handle); $processedHeaders = gpRemoteGet::processHeaders($theHeaders); // If location is found, then assume redirect and redirect to location. if (isset($processedHeaders['headers']['location'])) { return gpRemoteGet::Redirect($processedHeaders, $r, $arrURL); } $strResponse = gpRemoteGet::chunkTransferDecode($strResponse, $processedHeaders); return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response'], 'cookies' => $processedHeaders['cookies']); }