php - Difference between getRawBody() and getBody() methods of Zend_Http_Response? -


hi wondring whats difference between $response->getbody() , $response->getrawbody();

$this->_client->seturi('http://www.google.com/ig?hl=en');         try {             $response = $this->_client->request();         }catch(zend_http_exception $e)         {             echo 'zend http client failed';         }         echo get_class($response);         if($response->issuccessful())         {            $response->getbody();            $response->getrawbody();          } 

getrawbody() returns body of http response is.

getbody() adjust headers i.e. decompresses content sent gzip or deflate content-encoding headers. or chunked transfer-encoding header.

the simplest way figure these questions out in @ code. great learning experience. code edited brevity.

public function getrawbody() {     return $this->body; }  public function getbody() {     $body = '';      // decode body if transfer-encoded     switch (strtolower($this->getheader('transfer-encoding'))) {         case 'chunked':             // handle chunked body             break;         // no transfer encoding, or unknown encoding extension:         default:             // return body             break;     }      // decode content-encoding (gzip or deflate) if needed     switch (strtolower($this->getheader('content-encoding'))) {          case 'gzip':              // handle gzip encoding             break;         case 'deflate':             // handle deflate encoding             break;         default:             break;     }      return $body; } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -