original_string: public static function forge(RequestInterface $request)
      {
          $headerSize = $request->getInfo(CURLINFO_HEADER_SIZE);
          $response   = $request->getRawResponse();
          $content    = (strlen($response) === $headerSize) ? '' : substr($response, $headerSize);
  
          $rawHeaders = rtrim(substr($response, 0, $headerSize));
          $headers    = [];
  
          foreach (preg_split('/(\\r?\\n)/', $rawHeaders) as $header) {
              if ($header) {
                  $headers[] = $header;
              } else {
                  $headers = [];
              }
          }
  
          $headerBag = [];
          $info      = $request->getInfo();
          $status    = explode(' ', $headers[0]);
          $status    = explode('/', $status[0]);
  
          unset($headers[0]);
  
          foreach ($headers as $header) {
              $headerPair = explode(': ', $header);
  
              if (count($headerPair) > 1) {
                  list($key, $value)     = $headerPair;
                  $headerBag[trim($key)] = trim($value);
              }
          }
  
          $response = new static($content, $info['http_code'], $headerBag);
          $response->setProtocolVersion($status[1]);
          $response->setCharset(substr(strstr($response->headers->get('Content-Type'), '='), 1));
  
          return $response;
      }
code: public static function forge(RequestInterface $request)
      {
          $headerSize = $request->getInfo(CURLINFO_HEADER_SIZE);
          $response   = $request->getRawResponse();
          $content    = (strlen($response) === $headerSize) ? '' : substr($response, $headerSize);
  
          $rawHeaders = rtrim(substr($response, 0, $headerSize));
          $headers    = [];
  
          foreach (preg_split('/(\\r?\\n)/', $rawHeaders) as $header) {
              if ($header) {
                  $headers[] = $header;
              } else {
                  $headers = [];
              }
          }
  
          $headerBag = [];
          $info      = $request->getInfo();
          $status    = explode(' ', $headers[0]);
          $status    = explode('/', $status[0]);
  
          unset($headers[0]);
  
          foreach ($headers as $header) {
              $headerPair = explode(': ', $header);
  
              if (count($headerPair) > 1) {
                  list($key, $value)     = $headerPair;
                  $headerBag[trim($key)] = trim($value);
              }
          }
  
          $response = new static($content, $info['http_code'], $headerBag);
          $response->setProtocolVersion($status[1]);
          $response->setCharset(substr(strstr($response->headers->get('Content-Type'), '='), 1));
  
          return $response;
      }
code_tokens: public static function forge ( RequestInterface $ request ) { $ headerSize = $ request -> getInfo ( CURLINFO_HEADER_SIZE ) ; $ response = $ request -> getRawResponse ( ) ; $ content = ( strlen ( $ response ) === $ headerSize ) ? '' : substr ( $ response , $ headerSize ) ; $ rawHeaders = rtrim ( substr ( $ response , 0 , $ headerSize ) ) ; $ headers = [ ] ; foreach ( preg_split ( '/(\\r?\\n)/' , $ rawHeaders ) as $ header ) { if ( $ header ) { $ headers [ ] = $ header ; } else { $ headers = [ ] ; } } $ headerBag = [ ] ; $ info = $ request -> getInfo ( ) ; $ status = explode ( ' ' , $ headers [ 0 ] ) ; $ status = explode ( '/' , $ status [ 0 ] ) ; unset ( $ headers [ 0 ] ) ; foreach ( $ headers as $ header ) { $ headerPair = explode ( ': ' , $ header ) ; if ( count ( $ headerPair ) > 1 ) { list ( $ key , $ value ) = $ headerPair ; $ headerBag [ trim ( $ key ) ] = trim ( $ value ) ; } } $ response = new static ( $ content , $ info [ 'http_code' ] , $ headerBag ) ; $ response -> setProtocolVersion ( $ status [ 1 ] ) ; $ response -> setCharset ( substr ( strstr ( $ response -> headers -> get ( 'Content-Type' ) , '=' ) , 1 ) ) ; return $ response ; }
docstring: Forge a new object based on a request.
  @param  RequestInterface $request
  @return Response
docstring_tokens: Forge a new object based on a request .