ZF-3199: Zend_Http_Response::fromString($response->asString()) breaks for chunked/compressed responses

Issue Type: Bug Created: 2008-05-05T15:56:01.000+0000 Last Updated: 2012-03-28T02:15:07.000+0000 Status: Resolved Fix version(s): - 1.6.2 (13/Oct/08)

Reporter: Keith Grennan (keithorama) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Http_Response

Related issues: Attachments:


Hi there,

It would be nice if the fromString() and asString() methods were symmetrical, so that a response serialized a string could be expected to unserialize correctly (and that the string-representation of the response itself is valid).

The problem is simply that asString() returns the decoded body - however the headers may still indicate content chunking or compression - so that when the text is fed back to fromString(), it expects the body to be chunked or compressed.

The fix is:

<pre class="highlight">
--- Response.php    (revision 3800)
+++ Response.php    (working copy)
@@ -394,7 +394,7 @@
     public function asString($br = "\n")
-        return $this->getHeadersAsString(true, $br) . $br . $this->getBody();
+        return $this->getHeadersAsString(true, $br) . $br . $this->getRawBody();

Would be nice if there was another method that did this, or an optional argument, if you don't want to change asString() for backwards compat reasons.

Thanks, Keith


Posted by old of Satoru Yoshida ( on 2008-09-01T01:40:08.000+0000

Solved in SVN r11175

Have you found an issue?

See the Overview section for more details.


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

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