|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36283 SOAPClient Compression Broken
Submitted: 2006-02-04 12:03 UTC Modified: 2006-02-07 13:58 UTC
From: adam at trachtenberg dot com Assigned: dmitry
Status: Closed Package: SOAP related
PHP Version: 5CVS-2006-02-04 (CVS) OS: Mac OS X / Linux
Private report: No CVE-ID:
 [2006-02-04 12:03 UTC] adam at trachtenberg dot com
SOAPClient compression seems broken. I see two problems.

First, the code places the Accept-Encoding and Content-Encoding HTTP headers before the POST /path HTTP/1.1 line, which is invalid HTTP. This causes 400 errors.

I fixed this by moving the logic for this section further down in the function. See this patch for more details: 

It works for me, but I did not verify this is a perfect fix.

Second, it seems impossible (or just not as documented) to trigger compression of out-going requests. I don't understand how "level" can evaluate to > 0 given the SOAP_COMPRESSION_* constants.

Do you need to also pass a gzip compression level (0-9) as part of the compression bit field? This is not part of the online documentation, which says you can do this:

$client = new SoapClient("some.wsdl",

This evaluates to 0x20. Inside php_http.c in the make_http_soap_request function, it then does:

if (zend_hash_find(Z_OBJPROP_P(this_ptr), "compression", sizeof("compression"), (void **)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_LONG) {
	int level = Z_LVAL_PP(tmp) & 0x0f;


  if (level > 0) {

0x20 & 0x0f evaluates to 0, so you never execute the last branch, and no compression is used.

Furthermore, since level seems to be passed into the compression functions as the gzip level, I don't know how that relates to the bit field.

I tries to verify this using the unit tests, but there are none for SOAPClient and compression.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-04 12:46 UTC]
Assigned to the maintainer.
 [2006-02-06 11:13 UTC]
Thank you for patch. The bug is fixed in CVS HEAD and PHP_5_1.

To compress outgoing requests just add compression level.

client = new SoapClient("some.wsdl",
  array('compression' => SOAP_COMPRESSION_ACCEPT |

 [2006-02-06 18:14 UTC] adam at trachtenberg dot com
Thanks for merging the patch and for clarifying that you need to pass the compression level.

If this is the case, I have another patch. It changes the bitmask from 0x0f to 0x09 because gzip only supports compression levels from [1-9].

Right now, you will get an gzip error if you pass in [10-15].
 [2006-02-07 13:58 UTC]
Fixed in CVS HEAD and PHP_5_1.
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Jan 17 23:01:41 2017 UTC