summaryrefslogtreecommitdiff
path: root/inc/HTTPClient.php
diff options
context:
space:
mode:
authorTom N Harris <tnharris@whoopdedo.org>2012-06-20 03:00:18 -0400
committerTom N Harris <tnharris@whoopdedo.org>2012-06-20 03:00:18 -0400
commit769b429a77368df14e3753f624466f658e971df6 (patch)
tree306216ba947cf3ebbea4ad11b88ccd0aa7239dac /inc/HTTPClient.php
parentfbf63b6e769b92fc1964c09132dfc937910d04f3 (diff)
downloadrpg-769b429a77368df14e3753f624466f658e971df6.tar.gz
rpg-769b429a77368df14e3753f624466f658e971df6.tar.bz2
HTTPClient will read up to max_bodysize if it can
Diffstat (limited to 'inc/HTTPClient.php')
-rw-r--r--inc/HTTPClient.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php
index 901c46ec9..b5e665cb1 100644
--- a/inc/HTTPClient.php
+++ b/inc/HTTPClient.php
@@ -402,6 +402,7 @@ class HTTPClient {
$r_body = '';
if((isset($this->resp_headers['transfer-encoding']) && $this->resp_headers['transfer-encoding'] == 'chunked')
|| (isset($this->resp_headers['transfer-coding']) && $this->resp_headers['transfer-coding'] == 'chunked')){
+ $abort = false;
do {
$chunk_size = '';
while (preg_match('/^[a-zA-Z0-9]?$/',$byte=$this->_readData($socket,1,'chunk'))){
@@ -417,18 +418,19 @@ class HTTPClient {
if ($this->max_bodysize_abort)
throw new HTTPClientException('Allowed response size exceeded');
$this->error = 'Allowed response size exceeded';
- break;
+ $chunk_size = $this->max_bodysize - strlen($r_body);
+ $abort = true;
}
- if ($chunk_size) {
+ if ($chunk_size > 0) {
$r_body .= $this->_readData($socket, $chunk_size, 'chunk');
$byte = $this->_readData($socket, 2, 'chunk'); // read trailing \r\n
}
- } while ($chunk_size);
+ } while ($chunk_size && !$abort);
}else{
// read entire socket
while (!feof($socket)) {
- $r_body .= $this->_readData($socket, 0, 'response', true);
+ $r_body .= $this->_readData($socket, -$this->max_bodysize, 'response', true);
$r_size = strlen($r_body);
if($this->max_bodysize && $r_size > $this->max_bodysize){
if ($this->max_bodysize_abort) {