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


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:

--- 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


Solved in SVN r11175