summaryrefslogtreecommitdiff
path: root/inc/HTTPClient.php
diff options
context:
space:
mode:
authorGina Haeussge <osd@foosel.net>2008-06-22 11:21:05 +0200
committerGina Haeussge <osd@foosel.net>2008-06-22 11:21:05 +0200
commit5b037208e131484949e86b50b6dd198dfd117708 (patch)
tree00042db91d1d8f8496708015f17c78a9c3698f77 /inc/HTTPClient.php
parent32951c6c0c3c45d1431b526556423e9484c29037 (diff)
downloadrpg-5b037208e131484949e86b50b6dd198dfd117708.tar.gz
rpg-5b037208e131484949e86b50b6dd198dfd117708.tar.bz2
HTTPClient: Allow limited retrieval without aborting
Introduces a new member variable "max_bodysize_abort" into the HTTP client. If this is set to true (which is the default), the HTTP client shows it current behvaiour of aborting with an error condition if the given max_bodysize is exceeded during retrieval. If it is set to false however, the HTTP client just stops retrieval but returns what it already got. This allows the retrieval of e.g. the first 10K of a web document for searching for pingback data. darcs-hash:20080622092105-2b4f5-28c4399123775d82986faf22c7d89ccb22a8e025.gz
Diffstat (limited to 'inc/HTTPClient.php')
-rw-r--r--inc/HTTPClient.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php
index ed0a3aec6..7474e1fd8 100644
--- a/inc/HTTPClient.php
+++ b/inc/HTTPClient.php
@@ -58,7 +58,8 @@ class HTTPClient {
var $cookies;
var $referer;
var $max_redirect;
- var $max_bodysize; // abort if the response body is bigger than this
+ var $max_bodysize;
+ var $max_bodysize_abort = true; // if set, abort if the response body is bigger than max_bodysize
var $header_regexp; // if set this RE must match against the headers, else abort
var $headers;
var $debug;
@@ -252,7 +253,8 @@ class HTTPClient {
if($this->max_bodysize && preg_match('/\r?\nContent-Length:\s*(\d+)\r?\n/i',$r_headers,$match)){
if($match[1] > $this->max_bodysize){
$this->error = 'Reported content length exceeds allowed response size';
- return false;
+ if ($this->max_bodysize_abort)
+ return false;
}
}
@@ -327,7 +329,10 @@ class HTTPClient {
if($this->max_bodysize && strlen($r_body) > $this->max_bodysize){
$this->error = 'Allowed response size exceeded';
- return false;
+ if ($this->max_bodysize_abort)
+ return false;
+ else
+ break;
}
} while ($chunk_size);
}else{
@@ -342,7 +347,10 @@ class HTTPClient {
$r_size = strlen($r_body);
if($this->max_bodysize && $r_size > $this->max_bodysize){
$this->error = 'Allowed response size exceeded';
- return false;
+ if ($this->max_bodysize_abort)
+ return false;
+ else
+ break;
}
if($this->resp_headers['content-length'] && !$this->resp_headers['transfer-encoding'] &&
$this->resp_headers['content-length'] == $r_size){