ZF-3341: Content-Length is not set if the body is empty


When calling prepare_body() if the body is null content-length is not sent. This causes IIS to return

Length Required

rather than the requested return page.

To correct this issue I have added an else which returns 0 for content-length if the body is not specified.

Client.php line 982

    if ($body) {
        $this->setHeaders('Content-length', strlen($body));
    } else {
        $this->setHeaders('Content-length', '0');

IIS correctly returns the expected page. This appears only when the body of a post is empty so it is a unusual edge case but the content-length should still always be sent.


Also causes breakage with Zend_Service_Nirvanix. According to Mike Naberezny, "defaulting the content length to zero seems sane to me".

I think I have a patch for this (basically defaulting the 'content-length' header to 0 as suggested) but I need to somehow test this before I commit.

Can you provide some test code reproducing the Nirvanix breakage?


The attached file will let you test the problem. If the problem is fixed an exception should be raised as follows:

Fatal error: Uncaught exception 'Zend_Service_Nirvanix_Exception' with message 'Missing Required Parameter: appKey, username, password' in D:\PHP5\website\library\Zend\Service\Nirvanix\Response.php:119

Should be fixed in r. 9607 - please test and reopen if you still have problems.

Updating for the 1.6.0 release.