![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| Pear Pear programming, this is a very complex subject as with using pear with php can be a difficult task for some, so lets talk pear. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| avb Fri May 18 18:27:32 2007 UTC Modified files: /pear/HTTP_Request Request.php Log: Fixed bug #10605 (wrong Content-Length if using mbstring.func_overload) Use mbstring functions where applicable in case of mbstring.func_overload, this allows using gzip http://cvs.php.net/viewvc.cgi/pear/H...&diff_format=u Index: pear/HTTP_Request/Request.php diff -u pear/HTTP_Request/Request.php:1.53 pear/HTTP_Request/Request.php:1.54 --- pear/HTTP_Request/Request.php:1.53 Fri May 18 10:28:06 2007 +++ pear/HTTP_Request/Request.php Fri May 18 18:27:32 2007 @@ -40,7 +40,7 @@ * @author Alexey Borzov <avb@php.net> * @copyright 2002-2007 Richard Heyes * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Request.php,v 1.53 2007/05/18 10:28:06 avb Exp $ + * @version CVS: $Id: Request.php,v 1.54 2007/05/18 18:27:32 avb Exp $ * @link http://pear.php.net/package/HTTP_Request/ */ @@ -76,6 +76,18 @@ define('HTTP_REQUEST_HTTP_VER_1_1', '1.1', true); /**#@-*/ +if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { + /** + * Whether string functions are overloaded by their mbstring equivalents + */ + define('HTTP_REQUEST_MBSTRING', true); +} else { + /** + * @ignore + */ + define('HTTP_REQUEST_MBSTRING', false); +} + /** * Class for performing HTTP requests * @@ -317,10 +329,7 @@ } // Use gzip encoding if possible - // Avoid gzip encoding if using multibyte functions (see #1781) - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && extension_loaded('zlib') && - 0 == (2 & ini_get('mbstring.func_overload'))) { - + if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && extension_loaded('zlib')) { $this->addHeader('Accept-Encoding', 'gzip'); } } @@ -942,13 +951,17 @@ } $postdata .= '--' . $boundary . "--\r\n"; } - $request .= 'Content-Length: ' . strlen($postdata) . "\r\n\r\n"; + $request .= 'Content-Length: ' . + (HTTP_REQUEST_MBSTRING? mb_strlen($postdata, 'iso-8859-1'): strlen($postdata)) . + "\r\n\r\n"; $request .= $postdata; // Explicitly set request body } elseif (!empty($this->_body)) { - $request .= 'Content-Length: ' . strlen($this->_body) . "\r\n\r\n"; + $request .= 'Content-Length: ' . + (HTTP_REQUEST_MBSTRING? mb_strlen($this->_body, 'iso-8859-1'): strlen($this->_body)) . + "\r\n\r\n"; $request .= $this->_body; } @@ -1185,7 +1198,7 @@ $data = $this->_sock->read(4096); } else { $data = $this->_sock->read(min(4096, $this->_toRead)); - $this->_toRead -= strlen($data); + $this->_toRead -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data); } if ('' == $data) { break; @@ -1317,7 +1330,7 @@ } } $data = $this->_sock->read($this->_chunkLength); - $this->_chunkLength -= strlen($data); + $this->_chunkLength -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data); if (0 == $this->_chunkLength) { $this->_sock->readLine(); // Trailing CRLF } @@ -1354,6 +1367,10 @@ */ function _decodeGzip($data) { + if (HTTP_REQUEST_MBSTRING) { + $oldEncoding = mb_internal_encoding(); + mb_internal_encoding('iso-8859-1'); + } $length = strlen($data); // If it doesn't look like gzip-encoded data, don't bother if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { @@ -1429,6 +1446,9 @@ } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { return PEAR::raiseError('_decodeGzip(): data CRC check failed'); } + if (HTTP_REQUEST_MBSTRING) { + mb_internal_encoding($oldEncoding); + } return $unpacked; } } // End class HTTP_Response | |||
| Featured Websites | ||||
|
![]() |
| Tags: cvs, http_request, pear, requestphp |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cvs: pear /HTTP_Request Request.php | Alexey Borzov | Pear | 0 | 05-20-2007 7:42 PM |
| cvs: pear /HTTP_Request/Request Listener.php /HTTP_Request/docs download-progress.php example.php | Alexey Borzov | Pear | 0 | 05-20-2007 7:42 PM |
| cvs: pear-core / package-PEAR.xml package2.xml /PEAR Installer.php /PEAR/PackageFile v1.php /PEAR/PackageFile/v2 Validator.php | Greg Beaver | Pear | 0 | 05-20-2007 7:42 PM |
| [PEAR-ACCOUNT-REQUEST] Your bug tracker account request | johannes graën | Pear | 0 | 05-20-2007 7:41 PM |
| [ANNOUNCEMENT] HTTP_Request-1.4.1 (stable) Released. | PEAR Announce | Pear | 0 | 05-20-2007 6:34 PM |
| Featured Websites | ||||
|