|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-09-07 08:03 UTC] maggus dot staab at googlemail dot com
Description:
------------
SoapServer->handle() reports a bad-request when issuing a request with gzip.
triggering the very same request without gzip encoding works as expected.
SoapServer seems not to be able to read and parse the posted XML body.
the error is reproducible on php 5.6.23 and 7.0.10.
the testscript works (both in gzip and non-gzip) on php 5.4.45 (on ubuntu12 lts)
here some detail of the involved php versions:
mstaab@mst14:~$ php -v
PHP 7.0.10-2+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.10-2+deb.sury.org~trusty+1, Copyright (c) 1999-2016, by Zend Technologies
with blackfire v1.12.0, https://blackfire.io, by Blackfireio Inc.
mstaab@mst14:~$ php5 -v
PHP 5.6.23-1+deprecated+dontuse+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Zend Debugger v8.0.0, Copyright (c) 1999-2014, by Zend Technologies
with blackfire v1.12.0, https://blackfire.io, by Blackfireio Inc.
mstaab@vStaab12:~$ php -v
PHP 5.4.45-3+deb.sury.org~precise+1 (cli) (built: Jan 7 2016 15:32:17)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with Zend Debugger v6.0.0, Copyright (c) 1999-2013, by Zend Technologies
with blackfire v1.11.1, https://blackfire.io, by Blackfireio Inc.
Test script:
---------------
mstaab@mst14:~$ cat server.php
<?php
$s = new SoapServer(NULL, array('uri' => 'http://localhost/server.php'));
$s->setObject(new stdclass());
$s->handle();
mstaab@mst14:~$ cat postgz.sh
#!/bin/bash
curl \
-H "Content-Type: application/soap+xml; charset=UTF-8" \
-H "Accept: application/soap+xml, application/dime, multipart/related, text/*" \
-H 'SOAPAction: "urn:adressen#adressen#SetAda"' \
-H 'Content-Encoding: gzip' \
--data-binary @<(cat cd_catalog.xml | gzip) \
-X POST http://localhost:8000/server.php
mstaab@mst14:~$ cat post.sh
#!/bin/bash
curl \
-H "Content-Type: application/soap+xml; charset=UTF-8" \
-H "Accept: application/soap+xml, application/dime, multipart/related, text/*" \
-H 'SOAPAction: "urn:adressen#adressen#SetAda"' \
--data-binary @<(cat cd_catalog.xml) \
-X POST http://localhost:8000/server.php
cd_catalog.xml can be found at https://gist.github.com/staabm/fc96933585c11fe277b658c62c877345
you just need to start the builtin-webserver using php -S localhost:8000 and trigger post.sh respec. postgz.sh
Expected result:
----------------
mstaab@vStaab12:~$ ./post.sh
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><env:Fault><env:Code><env:Value>env:Receiver</env:Value></env:Code><env:Reason><env:Text>Function 'CATALOG't exist</env:Text></env:Reason></env:Fault></env:Body></env:Envelope>
mstaab@vStaab12:~$ ./postgz.sh
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><env:Fault><env:Code><env:Value>env:Receiver</env:Value></env:Code><env:Reason><env:Text>Function 'CATALOG't exist</env:Text></env:Reason></env:Fault></env:Body></env:Envelope>
Actual result:
--------------
mstaab@mst14:~$ ./post.sh
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><env:Fault><env:Code><env:Value>env:Receiver</env:Value></env:Code><env:Reason><env:Text>Function 'CATALOG't exist</env:Text></env:Reason></env:Fault></env:Body></env:Envelope>
mstaab@mst14:~$ ./postgz.sh
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Bad Request</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
Patchesbug73037.try.2.patch (last revision 2016-09-16 13:52 UTC by ab@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 19:00:01 2025 UTC |
I had looked at the issue and it's not related to any extension (only zlib, soap and libxml code is ever called). There's something fishy when _php_stream_read() is called recursively though. Thus simple code like: class simple_filter extends php_user_filter { function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } return PSFS_PASS_ON; } } stream_filter_register("simple", "simple_filter"); file_get_contents("php://filter/read=simple/resource=http://google.com"); is also failing in PHP 7. (works flawlessly with PHP 5.)I repro the case with gzip compression. But from what i could debug, it looks rather like an issue with the exact case, not with the streams. The compressed data arrives, but the wrapping stream doesn't eat all the uncompressed buffer. Right now it looks like an issue with XML parser in conjunction with streams. The internal stream buffer is 8192 bytes, any data smaller than that seems to come through. Also, a simple snippet without XML parser works, too. Like $fd = fopen("php://input", "rb"); stream_filter_append($fd, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 0x2f)); $in = ""; while (!feof($fd)) { $in .= fread($fd, 1024); } fclose($fd); I was able to track this down to PHP 5.5 already. Digging further on this. Bob, i currently don't see, how the other snippet is connected to this. Works in both 5 and 7 on my side. Maybe it's also about buffered enclosed stream. Didn't try anything else, but google seems to deliver the whole page, though always different size. Thanks.