if(($redirects > 8) || (! $ch))
return false;
- curl_setopt($ch, CURLOPT_HEADER, false);
+ curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
// by default we will allow self-signed certs
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header = substr($s,0,strpos($s,"\r\n\r\n"));
+ if(stristr($header,'100') && (strlen($header) < 30)) {
+ // 100 Continue has two headers, get the real one
+ $s = substr($s,strlen($header)+4);
+ $header = substr($s,0,strpos($s,"\r\n\r\n"));
+ }
if($http_code == 301 || $http_code == 302 || $http_code == 303) {
$matches = array();
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
$a->set_curl_headers($header);
curl_close($ch);
- return($s);
+ return($body);
}}
// post request to $url. $params is an array of post variables.
if(($redirects > 8) || (! $ch))
return false;
- curl_setopt($ch, CURLOPT_HEADER, false);
+ curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header = substr($s,0,strpos($s,"\r\n\r\n"));
+ if(stristr($header,'100') && (strlen($header) < 30)) {
+ // 100 Continue has two headers, get the real one
+ $s = substr($s,strlen($header)+4);
+ $header = substr($s,0,strpos($s,"\r\n\r\n"));
+ }
if($http_code == 301 || $http_code == 302 || $http_code == 303) {
$matches = array();
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
$a->set_curl_headers($header);
curl_close($ch);
- return($s);
+ return($body);
}}
// random hash, 64 chars