cvs: pear /HTTP_Request2 Request2.php /HTTP_Request2/Request2/Adapter Curl.php Socket.php /HTTP_Request2/tests Request2Test.php

From: Date: Fri, 03 Apr 2009 21:32:48 +0000
Subject: cvs: pear /HTTP_Request2 Request2.php /HTTP_Request2/Request2/Adapter Curl.php Socket.php /HTTP_Request2/tests Request2Test.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-55878@lists.php.net to get a copy of this message
avb Fri Apr 3 21:32:48 2009 UTC Modified files: /pear/HTTP_Request2 Request2.php /pear/HTTP_Request2/Request2/Adapter Curl.php Socket.php /pear/HTTP_Request2/tests Request2Test.php Log: It is possible to prevent saving the response body in response object (request #15881) HTTP_Request2::setHeader() now works as advertised, setHeader('Expect', '') will set a header with an empty value (bug #15937) http://cvs.php.net/viewvc.cgi/pear/HTTP_Request2/Request2.php?r1=1.11&r2=1.12&diff_format=u Index: pear/HTTP_Request2/Request2.php diff -u pear/HTTP_Request2/Request2.php:1.11 pear/HTTP_Request2/Request2.php:1.12 --- pear/HTTP_Request2/Request2.php:1.11 Wed Jan 28 21:16:08 2009 +++ pear/HTTP_Request2/Request2.php Fri Apr 3 21:32:48 2009 @@ -37,7 +37,7 @@ * @package HTTP_Request2 * @author Alexey Borzov <avb@php.net> * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Request2.php,v 1.11 2009/01/28 21:16:08 avb Exp $ + * @version CVS: $Id: Request2.php,v 1.12 2009/04/03 21:32:48 avb Exp $ * @link http://pear.php.net/package/HTTP_Request2 */ @@ -149,6 +149,7 @@ 'use_brackets' => true, 'protocol_version' => '1.1', 'buffer_size' => 16384, + 'store_body' => true, 'proxy_host' => '', 'proxy_port' => '', @@ -310,6 +311,9 @@ * <li> 'use_brackets' - Whether to append [] to array variable names (bool)</li> * <li> 'protocol_version' - HTTP Version to use, '1.0' or '1.1' (string)</li> * <li> 'buffer_size' - Buffer size to use for reading and writing (int)</li> + * <li> 'store_body' - Whether to store response body in response object. + * Set to false if receiving a huge response and + * using an Observer to save it (boolean)</li> * <li> 'proxy_host' - Proxy server host (string)</li> * <li> 'proxy_port' - Proxy server port (integer)</li> * <li> 'proxy_user' - Proxy auth username (string)</li> @@ -446,7 +450,7 @@ } } } else { - if (!$value && strpos($name, ':')) { + if (null === $value && strpos($name, ':')) { list($name, $value) = array_map('trim', explode(':', $name, 2)); } // Header name should be a token: http://tools.ietf.org/html/rfc2616#section-4.2 @@ -455,7 +459,7 @@ } // Header names are case insensitive anyway $name = strtolower($name); - if (!$value) { + if (null === $value) { unset($this->headers[$name]); } else { $this->headers[$name] = $value; http://cvs.php.net/viewvc.cgi/pear/HTTP_Request2/Request2/Adapter/Curl.php?r1=1.8&r2=1.9&diff_format=u Index: pear/HTTP_Request2/Request2/Adapter/Curl.php diff -u pear/HTTP_Request2/Request2/Adapter/Curl.php:1.8 pear/HTTP_Request2/Request2/Adapter/Curl.php:1.9 --- pear/HTTP_Request2/Request2/Adapter/Curl.php:1.8 Wed Jan 28 21:16:09 2009 +++ pear/HTTP_Request2/Request2/Adapter/Curl.php Fri Apr 3 21:32:48 2009 @@ -37,7 +37,7 @@ * @package HTTP_Request2 * @author Alexey Borzov <avb@php.net> * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Curl.php,v 1.8 2009/01/28 21:16:09 avb Exp $ + * @version CVS: $Id: Curl.php,v 1.9 2009/04/03 21:32:48 avb Exp $ * @link http://pear.php.net/package/HTTP_Request2 */ @@ -373,7 +373,9 @@ if (empty($this->response)) { throw new HTTP_Request2_Exception("Malformed response: {$string}"); } - $this->response->appendBody($string); + if ($this->request->getConfig('store_body')) { + $this->response->appendBody($string); + } $this->request->setLastEvent('receivedBodyPart', $string); return strlen($string); } http://cvs.php.net/viewvc.cgi/pear/HTTP_Request2/Request2/Adapter/Socket.php?r1=1.10&r2=1.11&diff_format=u Index: pear/HTTP_Request2/Request2/Adapter/Socket.php diff -u pear/HTTP_Request2/Request2/Adapter/Socket.php:1.10 pear/HTTP_Request2/Request2/Adapter/Socket.php:1.11 --- pear/HTTP_Request2/Request2/Adapter/Socket.php:1.10 Wed Jan 28 20:19:22 2009 +++ pear/HTTP_Request2/Request2/Adapter/Socket.php Fri Apr 3 21:32:48 2009 @@ -37,7 +37,7 @@ * @package HTTP_Request2 * @author Alexey Borzov <avb@php.net> * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Socket.php,v 1.10 2009/01/28 20:19:22 avb Exp $ + * @version CVS: $Id: Socket.php,v 1.11 2009/04/03 21:32:48 avb Exp $ * @link http://pear.php.net/package/HTTP_Request2 */ @@ -856,7 +856,9 @@ } $hasBody = true; - $response->appendBody($data); + if ($this->request->getConfig('store_body')) { + $response->appendBody($data); + } if (!in_array($response->getHeader('content-encoding'), array('identity', null))) { $this->request->setLastEvent('receivedEncodedBodyPart', $data); } else { http://cvs.php.net/viewvc.cgi/pear/HTTP_Request2/tests/Request2Test.php?r1=1.6&r2=1.7&diff_format=u Index: pear/HTTP_Request2/tests/Request2Test.php diff -u pear/HTTP_Request2/tests/Request2Test.php:1.6 pear/HTTP_Request2/tests/Request2Test.php:1.7 --- pear/HTTP_Request2/tests/Request2Test.php:1.6 Fri Jan 23 18:01:57 2009 +++ pear/HTTP_Request2/tests/Request2Test.php Fri Apr 3 21:32:48 2009 @@ -37,7 +37,7 @@ * @package HTTP_Request2 * @author Alexey Borzov <avb@php.net> * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Request2Test.php,v 1.6 2009/01/23 18:01:57 avb Exp $ + * @version CVS: $Id: Request2Test.php,v 1.7 2009/04/03 21:32:48 avb Exp $ * @link http://pear.php.net/package/HTTP_Request2 */ @@ -162,6 +162,19 @@ $this->fail('Expected HTTP_Request2_Exception was not thrown'); } + public function testBug15937() + { + $req = new HTTP_Request2(); + $autoHeaders = $req->getHeaders(); + + $req->setHeader('Expect: '); + $req->setHeader('Foo', ''); + $this->assertEquals( + array('expect' => '', 'foo' => '') + $autoHeaders, + $req->getHeaders() + ); + } + public function testCookies() { $req = new HTTP_Request2();

« previous php.pear.cvs (#55878) next »