PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Web Services » SOAP » Bug #9797

Problem sending http request with uft-8 encoded strings

Details

Submitted2007-01-10 15:44 UTC
Frompaolo dot mosna at gmail dot com
StatusBogus
PackageSOAP
PHP Version4.4.2
OSLinux
Roadmaps(Not assigned)

Comments

[2007-01-10 15:44 UTC] paolo dot mosna at gmail dot com

Description:
------------
The function _getRequest() in class SOAP_Transport_HTTP uses function strlen() to determine the attribute "Content-Length" for the HTTP request.
Function strlen() return the number of characters composing the string and not - as required - the number of bytes of the string. This leads to a situation where the request attribute "Content-lenght" contains a wrong number ob bytes when input string is UTF8 encoded. In this case strlen() doesn't return the number of bytes of the string but the number of characters.

The same problem is present in function _sendHTTP():
if (!fputs($fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {...}

The code uses strlen() to deteremine the number of bytes to send. In case of utf8 strings the method strlen() doesn't return the number of bytes to send, but the number of characters the string is composed, but this is different from the number of byte to send over HTTP request.

To fix the problem we created a new function called _strBytes() which returns the lenght of the string in bytes. This function has been used to replace use of strlen() is aforementioned code.