original_string: protected function handleResponse($response)
      {
          $ch = $this->ch;
  
          if (false !== $response) {
              $curlInfo = curl_getinfo($ch);
  
              // Parse response header
              if ($this->getCurlOption(CURLOPT_HEADER)) {
                  // Fixes header size error when use CURLOPT_PROXY and CURLOPT_HTTPPROXYTUNNEL is true
                  // http://sourceforge.net/p/curl/bugs/1204/
                  if (false !== stripos($response, "HTTP/1.1 200 Connection established\r\n\r\n")) {
                      $response = str_ireplace("HTTP/1.1 200 Connection established\r\n\r\n", '', $response);
                  }
  
                  $this->responseHeader = trim(substr($response, 0, $curlInfo['header_size']));
                  $this->responseText = substr($response, $curlInfo['header_size']);
              } else {
                  $this->responseText = $response;
              }
  
              $statusCode = $curlInfo['http_code'];
              $isSuccess = $statusCode >= 200 && $statusCode < 300 || $statusCode === 304;
              if ($isSuccess) {
                  $this->response = $this->parseResponse($this->responseText, $exception);
                  if (!$exception) {
                      $this->result = true;
                      $this->success && call_user_func($this->success, $this->response, $this);
                  } else {
                      $this->triggerError('parser', $exception);
                  }
              } else {
                  if ($this->responseHeader) {
                      preg_match('/[\d]{3} (.+?)\r/', $this->responseHeader, $matches);
                      $statusText = $matches[1];
                  } else {
                      $statusText = 'HTTP request error';
                  }
                  // + 1000 to avoid conflicts with error service 404 detection
                  $exception = new \ErrorException($statusText, $statusCode + 1000);
                  $this->triggerError('http', $exception);
              }
          } else {
              $exception = new \ErrorException(curl_error($ch), curl_errno($ch));
              $this->triggerError('curl', $exception);
          }
      }
code: protected function handleResponse($response)
      {
          $ch = $this->ch;
  
          if (false !== $response) {
              $curlInfo = curl_getinfo($ch);
  
              // Parse response header
              if ($this->getCurlOption(CURLOPT_HEADER)) {
                  // Fixes header size error when use CURLOPT_PROXY and CURLOPT_HTTPPROXYTUNNEL is true
                  // http://sourceforge.net/p/curl/bugs/1204/
                  if (false !== stripos($response, "HTTP/1.1 200 Connection established\r\n\r\n")) {
                      $response = str_ireplace("HTTP/1.1 200 Connection established\r\n\r\n", '', $response);
                  }
  
                  $this->responseHeader = trim(substr($response, 0, $curlInfo['header_size']));
                  $this->responseText = substr($response, $curlInfo['header_size']);
              } else {
                  $this->responseText = $response;
              }
  
              $statusCode = $curlInfo['http_code'];
              $isSuccess = $statusCode >= 200 && $statusCode < 300 || $statusCode === 304;
              if ($isSuccess) {
                  $this->response = $this->parseResponse($this->responseText, $exception);
                  if (!$exception) {
                      $this->result = true;
                      $this->success && call_user_func($this->success, $this->response, $this);
                  } else {
                      $this->triggerError('parser', $exception);
                  }
              } else {
                  if ($this->responseHeader) {
                      preg_match('/[\d]{3} (.+?)\r/', $this->responseHeader, $matches);
                      $statusText = $matches[1];
                  } else {
                      $statusText = 'HTTP request error';
                  }
                  // + 1000 to avoid conflicts with error service 404 detection
                  $exception = new \ErrorException($statusText, $statusCode + 1000);
                  $this->triggerError('http', $exception);
              }
          } else {
              $exception = new \ErrorException(curl_error($ch), curl_errno($ch));
              $this->triggerError('curl', $exception);
          }
      }
code_tokens: protected function handleResponse ( $ response ) { $ ch = $ this -> ch ; if ( false !== $ response ) { $ curlInfo = curl_getinfo ( $ ch ) ; // Parse response header if ( $ this -> getCurlOption ( CURLOPT_HEADER ) ) { // Fixes header size error when use CURLOPT_PROXY and CURLOPT_HTTPPROXYTUNNEL is true // http://sourceforge.net/p/curl/bugs/1204/ if ( false !== stripos ( $ response , "HTTP/1.1 200 Connection established\r\n\r\n" ) ) { $ response = str_ireplace ( "HTTP/1.1 200 Connection established\r\n\r\n" , '' , $ response ) ; } $ this -> responseHeader = trim ( substr ( $ response , 0 , $ curlInfo [ 'header_size' ] ) ) ; $ this -> responseText = substr ( $ response , $ curlInfo [ 'header_size' ] ) ; } else { $ this -> responseText = $ response ; } $ statusCode = $ curlInfo [ 'http_code' ] ; $ isSuccess = $ statusCode >= 200 && $ statusCode < 300 || $ statusCode === 304 ; if ( $ isSuccess ) { $ this -> response = $ this -> parseResponse ( $ this -> responseText , $ exception ) ; if ( ! $ exception ) { $ this -> result = true ; $ this -> success && call_user_func ( $ this -> success , $ this -> response , $ this ) ; } else { $ this -> triggerError ( 'parser' , $ exception ) ; } } else { if ( $ this -> responseHeader ) { preg_match ( '/[\d]{3} (.+?)\r/' , $ this -> responseHeader , $ matches ) ; $ statusText = $ matches [ 1 ] ; } else { $ statusText = 'HTTP request error' ; } // + 1000 to avoid conflicts with error service 404 detection $ exception = new \ ErrorException ( $ statusText , $ statusCode + 1000 ) ; $ this -> triggerError ( 'http' , $ exception ) ; } } else { $ exception = new \ ErrorException ( curl_error ( $ ch ) , curl_errno ( $ ch ) ) ; $ this -> triggerError ( 'curl' , $ exception ) ; } }
docstring: Parse response text
  
  @param string $response
docstring_tokens: Parse response text