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

Issue Type: Bug Created: 2008-05-28T10:03:35.000+0000 Last Updated: 2008-09-02T10:39:15.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)

Reporter: Barry Ruffner (bruffner) Assignee: Shahar Evron (shahar) Tags: - Zend_Http_Client

Related issues: Attachments: - zendtest.php


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.


Posted by Matthew Weier O'Phinney (matthew) on 2008-05-28T10:21:33.000+0000

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

Posted by Shahar Evron (shahar) on 2008-05-30T14:17:05.000+0000

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?


Posted by Barry Ruffner (bruffner) on 2008-06-02T10:26:04.000+0000

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

Posted by Shahar Evron (shahar) on 2008-06-04T09:48:42.000+0000

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

Posted by Wil Sinclair (wil) on 2008-09-02T10:39:15.000+0000

Updating for the 1.6.0 release.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.