Re: Bug in HTTP stream context causes problems in SoapClient/get_sdl()
| From: | Hannes Magnusson | Date: | Sun, 25 Jan 2009 22:06:51 +0000 |
| Subject: | Re: Bug in HTTP stream context causes problems in SoapClient/get_sdl() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42835@lists.php.net to get a copy of this message | ||
On Sun, Jan 25, 2009 at 22:43, Giovanni Giacobbi <giovanni@giacobbi.net> wrote:
>
> The problem turned out to be an invalid interpretation of the HTTP/1.1 protocol with
> "Transfer-Encoding: chunked" by the HTTP stream context, which caused get_sdl() to parse a
> WSDL including the chunk tags (hex numbers).
>
> Chunked encoding is used by Apache 2.0 when "Content-Length" is unavailable, the data
> content being sent is large enough, and the protocol is HTTP/1.1.
>
PHP streams do not support chunked encoding, and I assume SOAP doesn't
either (although it does reinvent bunch of things, I don't think
chunked encoding was added). I thought the docs were quite explicit on
the subject.. if not, please open a doc bug.
> <?php
> $opts = array('http' => array('method' => "GET",
> 'header' => "Accept-language: en\r\nConnection: close\r\n"));
> $context = stream_context_create($opts);
> stream_context_set_option($context, "http", "protocol_version", 1.1);
> fpassthru(fopen('http://localhost/ws/catalog?wsdl',
> 'r', false, $context));
> ?>
Changing the protocol version is "at your own risk".
If you want a full real HTTP support, you have to use the pecl/http extension.
> 2) Without the "Connection: close" header the stream blocks until http timeout. It
> should instead detect the chunk with 0 bytes and return from the fpassthru().
>
That however is a valid bug, which I have actually seen couple of
times myself.. never debugged it and just assumed I did something
weird :]
-Hannes