php.net |  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 (profile)
Status: Closed Package: SOAP related
PHP Version: 5CVS-2006-02-04 (CVS) OS: Mac OS X / Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: adam at trachtenberg dot com
New email:
PHP Version: OS:

 

 [2006-02-04 12:03 UTC] adam at trachtenberg dot com
Description:
------------
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:

http://www.trachtenberg.com/patches/soap_compression_patch.txt 

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",
  array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP));

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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-04 12:46 UTC] tony2001@php.net
Assigned to the maintainer.
 [2006-02-06 11:13 UTC] dmitry@php.net
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 |
SOAP_COMPRESSION_GZIP | 9));

 [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].

http://www.trachtenberg.com/patches/soap_compression_level_patch.txt

Right now, you will get an gzip error if you pass in [10-15].
 [2006-02-07 13:58 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_1.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC