aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Macgirvin <mike@macgirvin.com>2010-10-21 16:45:26 -0700
committerMike Macgirvin <mike@macgirvin.com>2010-10-21 16:45:26 -0700
commitd193763aa86d374e7b01afd0b5e2c26434c350d3 (patch)
treeef943ed0b033be35a3bd434724c276f55ab1028a
parenta266217a6d6376a2f43f66b9a9cc4aa5e4a8455a (diff)
downloadvolse-hubzilla-d193763aa86d374e7b01afd0b5e2c26434c350d3.tar.gz
volse-hubzilla-d193763aa86d374e7b01afd0b5e2c26434c350d3.tar.bz2
volse-hubzilla-d193763aa86d374e7b01afd0b5e2c26434c350d3.zip
fixed it. Twas the infernal 100 continue headers
-rw-r--r--boot.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/boot.php b/boot.php
index 0a1e799ec..6b23d38e0 100644
--- a/boot.php
+++ b/boot.php
@@ -354,7 +354,7 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
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
@@ -378,6 +378,11 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
$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);
@@ -394,7 +399,7 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
$a->set_curl_headers($header);
curl_close($ch);
- return($s);
+ return($body);
}}
// post request to $url. $params is an array of post variables.
@@ -405,7 +410,7 @@ function post_url($url,$params, &$redirects = 0) {
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);
@@ -425,6 +430,11 @@ function post_url($url,$params, &$redirects = 0) {
$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);
@@ -441,7 +451,7 @@ function post_url($url,$params, &$redirects = 0) {
$a->set_curl_headers($header);
curl_close($ch);
- return($s);
+ return($body);
}}
// random hash, 64 chars