Skip to content
Snippets Groups Projects
Commit 5b230a45 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

HTTPClient don't pull too much bytes when no content-length is given

parent 18ce55ed
No related branches found
No related tags found
No related merge requests found
......@@ -122,9 +122,14 @@ class httpclient_http_test extends DokuWikiTest {
function test_maxbody(){
$http = new HTTPClient();
$http->max_bodysize = 250;
// this should abort completely
$data = $http->get($this->server.'/stream/30');
$this->assertTrue($data === false, 'HTTP response');
// this should read just the needed bytes
$http->max_bodysize_abort = false;
$http->keep_alive = false;
$data = $http->get($this->server.'/stream/30');
$this->assertFalse($data === false, 'HTTP response');
/* should read no more than max_bodysize+1 */
......
......@@ -463,6 +463,8 @@ class HTTPClient {
}
$r_body = $this->_readData($socket, $length, 'response (content-length limited)', true);
}elseif( !isset($this->resp_headers['transfer-encoding']) && $this->max_bodysize && !$this->keep_alive){
$r_body = $this->_readData($socket, $this->max_bodysize, 'response (content-length limited)', true);
}else{
// read entire socket
$r_size = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment