";
$headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
$theHeaders = trim( substr($theResponse, 0, $headerLength) );
if ( strlen($theResponse) > $headerLength )
$theBody = substr( $theResponse, $headerLength );
else
$theBody = '';
if ( false !== strpos($theHeaders, "\r\n\r\n") ) {
$headerParts = explode("\r\n\r\n", $theHeaders);
$theHeaders = $headerParts[ count($headerParts) -1 ];
}
} else {
echo 'there was no response
';
if ( $curl_error = curl_error($handle) )
echo $curl_error . "
";
if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) )
echo 'Too many redirects.' . "
" ;
$theHeaders = array( 'headers' => array(), 'cookies' => array() );
$theBody = '';
}
echo $theHeaders;
echo $theBody;
echo curl_getinfo( $handle, CURLINFO_HTTP_CODE );
}
test_it('http://www.informationweek.com/story/');