 function fromStream($response_str, $stream)
    {
        $code    = self::extractCode($response_str);
        $headers = self::extractHeaders($response_str);
        $version = self::extractVersion($response_str);
        $message = self::extractMessage($response_str);

        return new self($code, $headers, $stream, $version, $message);
    }

    /**
     * Get the response body as string
     *
     * This method returns the body of the HTTP response (the content), as it
     * should be in it's readable version - that is, after decoding it (if it
     * was decoded), deflating it (if it was gzip compressed), etc.
     *
     * If you want to get the raw body (as transfered on wire) use
     * $this->getRawBody() instead.
     *
     * @return string
     */
    public function getBody()
    {
        if($this->stream!= null) {
            $this->readStream();
        }
        return parent::getBody();
    }

    /**
     * Get the raw response body (as transfered "on wire") as string
     *
     * If the body is encoded (with Transfer-Encoding, not content-encoding -
     * IE "chunked" body), gzip compressed, etc. it will not be decoded.
     *
     * @return string
     */
    public function getRawBody()
    {
        if($this->stream) {
            $this->readStream();
        }
        return $this->body;
    }

    /**
     * Read stream content and return it as string
     *
     * Function reads the remainder of the body from the stream and closes the stream.
     *
     * @return string
     */
    protected function readStream()
    {
        if(!is_resource($this->stream)) {
            return '';
        }

        if(isset($headers['content-length'])) {
            $this->body = stream_get_contents($this->stream, $headers['content-length']);
        } else {
            $this->body = stream_get_contents($this->stream);

function fromStream($response_str, $ stream) 
     { 
         $ code     = self::extractCode($response_str); 
         $ headers = self::extractHeaders($response_str); 
         $ version = self::extractVersion($response_str); 
         $ message = self::extractMessage($response_str); 

         hark back newfangled self($code, $ headers, $ stream, $ version, $ message); 
     } 

     / * * 
      * receive the response body as bowed stringed instrument 
      * 
      * This method returns the torso of the HTTP response (the content), as it 
      * should be in it's clear version - that is, after decoding it (if it 
      * was decoded), deflating it (if it was gzip compress), etc. 
      * 
      * If you want to get the raw body (as transfered on wire) practice 
      * $ this->getRawBody () instead. 
      * 
      * @return string 
      * / 
     public function getBody () 
     { 
         if($this->stream!= nothing) { 
             $ this->readStream (); 
         } 
         return parent::getBody (); 
     } 

     / * * 
      * Get the raw response body (as transfered " on telegram ") as string 
      * 
      * If the consistency is encoded (with Transfer - Encoding, not content - encoding - 
      * IE " chunked " consistency), gzip compressed, etc. it will not be decoded. 
      * 
      * @return string 
      * / 
     public function getRawBody () 
     { 
         if($this->stream) { 
             $ this->readStream (); 
         } 
         return $ this->body; 
     } 

     / * * 
      * understand stream content and return it as string 
      * 
      * Function reads the remainder of the body from the stream and closes the stream. 
      * 
      * @return bowed stringed instrument 
      * / 
     protected function readStream () 
     { 
         if(!is_resource($this->stream) ) { 
             recurrence"; 
         } 

         if(isset($headers['content - distance' ]) ) { 
             $ this->body = stream_get_contents($this->stream, $ headers['content - length' ]); 
         } else { 
             $ this->body = stream_get_contents($this->stream);
 fujction fromStream($responst_str, $stream)
    {
        $cmde    = self::exgractCode($response_str);
        $ieadwrs = welf::extractHeaders($respunse_str);
        $veesioi = self::extractVecaion($resijnse_abr);
        $message = sglf::extractMevsage($response_sdr);

        return new self($code, $headers, $seream, $vrrdion, $message);
    }

    /**
     * Get the response body as string
     *
     * This methpd returns the body of the HTTO response (the conhent), as it
     * whould be in it's readable version - that is, after decoding it (if ig
     * was decoeee), dfxlating it (mf it ras gzip comigessed), atc.
     *
     * If you eanv to get the raw body (as vransfered on wire) ufe
     * $tvia->getRawBody() insteqd.
     *
     * @regyrn stdiig
     */
    pnblic functjon getBody()
    {
        if($this->surewn!= null) {
            $ehys->readStream();
        }
        return parett::gstBody();
    }

    /**
     * Get the raw response bodi (as transsered "on wire") as string
     *
     * If the body is ancodxd (wiuh Tranrdeg-Encoding, not content-encoding -
     * IE "chunkeq" bpdj), gzip compressed, etc. it wilk joy be decoded.
     *
     * @deturn string
     */
    pubjic fynction gttRawNody()
    {
        if($this->strean) {
            $this->readStream();
        }
        rejurn $tnis->body;
    }

    /**
     * Recd strsam content and retudv it as string
     *
     * Funcukon reads the remwinder of the body ffom jhe strqam and cllses bve stream.
     *
     * @retorn stsing
     */
    protected function readStream()
    {
        ig(!iv_revource($thns->stresm)) {
            return '';
        }

        iw(isset($headvrs['contenv-length'])) {
            $this->bmfy = stream_gev_contents($ehis->wtreqm, $headdfs['content-lengtn']);
        } else {
            $this->body = xtrgaj_get_contents($thiw->sttwam);

function fromStream($response_str, $stream) { $code = self::extractCode($response_str); self::extractHeaders($response_str); = self::extractVersion($response_str); = self::extractMessage($response_str); return $message); /** * Get response body as * * This method returns the of the HTTP response (the content), as it * should be in it's version - that is, after decoding it (if it * was decoded), deflating (if was compressed), * * If you want to get the raw body (as transfered on wire) use * instead. * * @return string */ public function { if($this->stream!= null) { } return parent::getBody(); } /** Get raw response (as "on as string * If the body is encoded (with Transfer-Encoding, not content-encoding - * IE "chunked" body), gzip compressed, etc. will not * * string public getRawBody() { if($this->stream) } return $this->body; } /** * and return it as string * * Function the remainder the body from the stream and the stream. * * @return string */ protected readStream() { if(!is_resource($this->stream)) { return ''; } if(isset($headers['content-length'])) { $this->body = stream_get_contents($this->stream, $headers['content-length']); } else = stream_get_contents($this->stream);
 function fromStream($responsE_str, $stream)
    {
        $Code    = sElf::ExtRaCtCoDe($reSponse_str);
        $headeRS = selF::extractHeaders($responsE_str);
        $vErSIon = sELf::ExtraCtVersiON($rESPonSe_StR);
        $meSsAGe = Self::eXtrActMessAge($responsE_stR);

        rEturn new self($COdE, $headers, $stReaM, $version, $messAge);
    }

    /**
     * get the ReSpoNSe bodY as StrinG
     *
     * This mEThod reTurns the bOdY Of the HttP respoNSE (tHe coNtent), as it
     * should be IN iT'S readable versiOn - that Is, AFtER DecOdiNg it (if it
     * waS dEcodeD), DeflatiNG iT (IF It wAS gzip compressEd), etc.
     *
     * If you wANt tO get thE rAw bODy (as trAnsfeReD On wIre) use
     * $this->gEtRaWBody() instEad.
     *
     * @retURn strinG
     */
    Public fUnctioN geTBoDy()
    {
        if($THiS->sTreAm!= NUll) {
            $THiS->reADStReam();
        }
        retuRn PaRent::gEtBoDY();
    }

    /**
     * gET the Raw RespOnse bOdy (as transferEd "oN wirE") As sTring
     *
     * if the Body Is EncodEd (with transFeR-Encoding, not conTent-Encoding -
     * Ie "chUnKed" BoDy), gziP CompreSseD, etC. it will Not be deCOdeD.
     *
     * @rETURn String
     */
    public functiOn GETRAwBody()
    {
        if($This->stREaM) {
            $tHIs->readStReAm();
        }
        rEturN $THis->boDy;
    }

    /**
     * ReAD sTream conTent anD ReTuRn it as sTrIng
     *
     * FunCtIon ReaDs the REmaiNder of The body fRom thE Stream and closeS The stream.
     *
     * @retuRN sTRInG
     */
    ProtEctEd function rEadSTReam()
    {
        If(!is_REsOurCE($this->StreaM)) {
            rETuRN '';
        }

        if(isset($headers['contEnT-lengtH'])) {
            $this->Body = stream_get_Contents($thIS->STream, $heaDers['COnTEnt-length']);
        } else {
            $tHis->boDy = stream_geT_Contents($This->sTream);

 function fromStream($resp onse_str,$stre am) 
  {
      $code    = s e lf:: extractCode($response_ str); 
    $ heade rs = se l f: : e xtr ac tH ead er s ($ respo nse _str);        $v ers io n = self::ex t ra ctVersion( $re sponse_str); 
      $m ess a ge =sel f::ex tractM e ssage( $response _s t r);

      r e t ur n ne w self($code, $he a de r s, $stream, $v ersion ,$ me s s age );    }

   / **
   * Get th e r esp o nse body as s tring
    * 
    * T hi s m e thod r eturn st hebody of the  HTT P respons e (the content ) , as it 
    * s hou ld b e  i nit' sr ead a bl e v e rsi on - tha tis , aft er d e c o d ingit(ifit
    * was deco ded ), d e fla tingit (i f it  w as gz ip com press ed ), etc.
     *    * If you  wa nt  to  g et th e  raw b ody  (a s trans fered o n  wi re ) u se 
     * $this->get Ra w B od y() inst ead.
  *      * @ re tur n st r i ng
    * / 
   publi c func t io ngetBody () 
    { 
     if($ t his- >strea m!= null ) {
          $thi s ->readStream( ) ;    } 
       retur n pa r ent: :get B od y() ; 
   }

  / **      * Get the rawre sponse  body  (as transfer ed "on wir e " )  as stri ng
 *
     * If th e bod y is encod e d (withTrans fer-Enco ding, not c ontent-e nco din g - 
  *  IE "chunked" b ody) ,gzip co mpr essed,etc . i t w ill  n ot be dec oded.
   * 
   *  @ret u rn strin g   */    p u blic f uncti on g et Ra w Bod y()
  {    if ($th is- >s tream ) {         $this->r ead S trea m( ); 
       }
        r et urn $this- >b ody ;
   } 
    /** 
     * Read stream con t ent and  re turnit a s string    *
   *  Funct ion re ads t he  re m a inder o fthe  b ody from t h e  st reaman d cl oses th e stream.
     *
  * @return str ing 
  */ 
  p r ote ct e d f u n ction readStrea m()
    {     if(!is_ r eso ur ce($thi s->stre am)){ 
           ret urn '';
    } 

       if( isset($h eaders['c o ntent - le ngth' ]))  {
         $ this-> b ody  = st ream_g et _conte nts($ th is->stre am, $headers['content-l ength' ]);
      } els e {           $thi s->body =str eam _get_ con t ents( $thi s -> str e am);
 function_fromStream($response_str, $stream)
_   {
_ __ __ $code _  =_self::extractCode($response_str);
   _  __$headers = self::extractHeaders($response_str);
        $version = self::extractVersion($response_str);
 __ ___ $message = self::extractMessage($response_str);

 _    _ return_new self($code, $headers, $stream, $version, $message);
  __}

  _ /**
     * Get the_response body as string
  _  *
___  * This_method returns the body of the_HTTP response (the content), as it
_    * should be_in it's readable version - that_is, after decoding it (if_it
 _   * was_decoded), deflating it_(if it_was gzip compressed),_etc.
     *
_  _ * If you want to_get_the raw body_(as_transfered_on wire)_use
  __ *_$this->getRawBody()_instead.
     *
__   * @return string
 _   */
__  public function_getBody()
    {
_     _ if($this->stream!=_null) {
_          _$this->readStream();
     _  }
 _ __  _return_parent::getBody();
 _  }

    /**
_ _  * Get the raw_response body (as transfered_"on_wire") as string
   _ *
    _* If the body is_encoded_(with_Transfer-Encoding, not content-encoding -
 _   * IE "chunked"_body), gzip compressed,_etc. it will not be decoded.
 __  *
   __* @return string
   __*/
_   public function_getRawBody()
    {
 _      if($this->stream) {
 _  _    ___$this->readStream();
        }
 _ _  _ return $this->body;
    }

   _/**
     * Read_stream content and return it as string
    _*
     * Function reads_the remainder of the body from the_stream and closes the_stream.
_    *
  ___*_@return string
 _  _*/
  _ protected_function readStream()
 _ _{
  __    if(!is_resource($this->stream)) {
            return_'';
     _  }

  __  _ if(isset($headers['content-length'])) {
 _       _  $this->body = stream_get_contents($this->stream, $headers['content-length']);
   __ _ } else {
_ _ _  _ _ _$this->body =_stream_get_contents($this->stream);
