From d37a395509092f21060e2a042a2be0ea759f6d0b Mon Sep 17 00:00:00 2001 From: Tom N Harris Date: Tue, 19 Jun 2012 03:17:21 -0400 Subject: Unit test for HTTPClient chunked encoding --- _test/tests/inc/httpclient_http.test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/httpclient_http.test.php b/_test/tests/inc/httpclient_http.test.php index 9cae3736a..cf8137152 100644 --- a/_test/tests/inc/httpclient_http.test.php +++ b/_test/tests/inc/httpclient_http.test.php @@ -176,5 +176,15 @@ class httpclient_http_test extends DokuWikiTest { $this->assertArrayHasKey('foo',$http->resp_headers); $this->assertEquals('bar',$http->resp_headers['foo']); } + + /** + * @group internet + */ + function test_chunked(){ + $http = new HTTPClient(); + $data = $http->get('http://whoopdedo.org/cgi-bin/chunked/2550'); + $this->assertFalse($data === false, 'HTTP response'); + $this->assertEquals(2550,strlen($data)); + } } //Setup VIM: ex: et ts=4 : -- cgit v1.2.3 From 769b429a77368df14e3753f624466f658e971df6 Mon Sep 17 00:00:00 2001 From: Tom N Harris Date: Wed, 20 Jun 2012 03:00:18 -0400 Subject: HTTPClient will read up to max_bodysize if it can --- _test/tests/inc/httpclient_http.test.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/httpclient_http.test.php b/_test/tests/inc/httpclient_http.test.php index cf8137152..c3ee182dc 100644 --- a/_test/tests/inc/httpclient_http.test.php +++ b/_test/tests/inc/httpclient_http.test.php @@ -124,6 +124,12 @@ class httpclient_http_test extends DokuWikiTest { $http->max_bodysize = 250; $data = $http->get($this->server.'/stream/30'); $this->assertTrue($data === false, 'HTTP response'); + $http->max_bodysize_abort = false; + $data = $http->get($this->server.'/stream/30'); + $this->assertFalse($data === false, 'HTTP response'); + /* the current implementation will read in max_bodysize blocks, + and aborts if the response is larger, thus a limit of 2*max_bodysize */ + $this->assertLessThanOrEqual(500,strlen($data)); } /** -- cgit v1.2.3 From 08118f511f456cc119c08a966a83704af88e6182 Mon Sep 17 00:00:00 2001 From: Tom N Harris Date: Sun, 1 Jul 2012 15:25:33 -0400 Subject: Adjust unit test to reflect desired behavior of max_bodysize --- _test/tests/inc/httpclient_http.test.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/httpclient_http.test.php b/_test/tests/inc/httpclient_http.test.php index c3ee182dc..9959a1f06 100644 --- a/_test/tests/inc/httpclient_http.test.php +++ b/_test/tests/inc/httpclient_http.test.php @@ -127,9 +127,8 @@ class httpclient_http_test extends DokuWikiTest { $http->max_bodysize_abort = false; $data = $http->get($this->server.'/stream/30'); $this->assertFalse($data === false, 'HTTP response'); - /* the current implementation will read in max_bodysize blocks, - and aborts if the response is larger, thus a limit of 2*max_bodysize */ - $this->assertLessThanOrEqual(500,strlen($data)); + /* should read no more than max_bodysize+1 */ + $this->assertLessThanOrEqual(251,strlen($data)); } /** -- cgit v1.2.3