aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-07-03 02:19:43 -0700
committerFriendika <info@friendika.com>2011-07-03 02:19:43 -0700
commit12b114f6adfa3f4cd1a50c832509f7205e5b7284 (patch)
treed927723bf4c88a720f3cc1f89c5c714d49b35e12
parentcffc4ef14d5ce10411f9e8f01638e9ba523f3c81 (diff)
downloadvolse-hubzilla-12b114f6adfa3f4cd1a50c832509f7205e5b7284.tar.gz
volse-hubzilla-12b114f6adfa3f4cd1a50c832509f7205e5b7284.tar.bz2
volse-hubzilla-12b114f6adfa3f4cd1a50c832509f7205e5b7284.zip
use another method to strip out headers
-rw-r--r--boot.php44
1 files changed, 14 insertions, 30 deletions
diff --git a/boot.php b/boot.php
index 35adae330..0e9abddd3 100644
--- a/boot.php
+++ b/boot.php
@@ -702,13 +702,12 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
$s = @curl_exec($ch);
- $http_code = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE));
- $header = substr($s,0,strpos($s,"\r\n\r\n"));
- if(preg_match('/HTTP\/.+? 100/',$header)) {
- // 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"));
- }
+ $curl_info = curl_getinfo($ch);
+ $header_size = $curl_info['header_size'];
+ $http_code = $curl_info['http_code'];
+
+ $header = substr($s,0,$header_size);
+
if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
$matches = array();
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
@@ -721,14 +720,7 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
}
$a->set_curl_code($http_code);
- $body = substr($s,strlen($header)+4);
-
- /* one more try to make sure there are no more headers */
-
- if(strpos($body,'HTTP/') === 0) {
- $header = substr($body,0,strpos($body,"\r\n\r\n"));
- $body = substr($body,strlen($header)+4);
- }
+ $body = substr($s,$header_size);
$a->set_curl_headers($header);
@@ -775,13 +767,12 @@ function post_url($url,$params, $headers = null, &$redirects = 0) {
$s = @curl_exec($ch);
- $http_code = intval(curl_getinfo($ch, CURLINFO_HTTP_CODE));
- $header = substr($s,0,strpos($s,"\r\n\r\n"));
- if(preg_match('/HTTP\/.+? 100/',$header)) {
- // 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"));
- }
+ $curl_info = curl_getinfo($ch);
+ $header_size = $curl_info['header_size'];
+ $http_code = $curl_info['http_code'];
+
+ $header = substr($s,0,$header_size);
+
if($http_code == 301 || $http_code == 302 || $http_code == 303) {
$matches = array();
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
@@ -793,14 +784,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0) {
}
}
$a->set_curl_code($http_code);
- $body = substr($s,strlen($header)+4);
-
- /* one more try to make sure there are no more headers */
-
- if(strpos($body,'HTTP/') === 0) {
- $header = substr($body,0,strpos($body,"\r\n\r\n"));
- $body = substr($body,strlen($header)+4);
- }
+ $body = substr($s,$header_size);
$a->set_curl_headers($header);