english/libraries/joomla/client/http.php
/**
	 * Method to get a response object from a server response.
	 *
	 * @return  JHttpResponse
	 *
	 * @since   11.1
	 * @throws  JException
	 */
Method to get a response object from a server response.


Method to get a response object from a server response .
protected function _getResponseObject()
	{
		$return = new JHttpResponse;
		$response = explode("\r\n\r\n", $this->_response, 2);
		$headers = explode("\r\n", $response[0]);
		preg_match('/[0-9]{3}/', array_shift($headers), $matches);
		$code = $matches[0];
		if (is_numeric($code)) {
			$return->code = (int) $code;
		}
		else {
			throw new JException('Invalid server response.', 0, E_WARNING, $this->_response);
		}
		foreach ($headers as $header)
		{
			$pos = strpos($header, ':');
			$return->headers[trim(substr($header, 0, $pos))] = trim(substr($header, ($pos + 1)));
		}
		if (!empty($response[1])) {
			$return->body = $response[1];
		}
		return $return;
	}
protected function _getResponseObject ( ) { $ return = new JHttpResponse ; $ response = explode ( " \r \n \r \n " , $ this -> _response , 2 ) ; $ headers = explode ( " \r \n " , $ response [ 0 ] ) ; preg_match ( '/[0-9]{3}/' , array_shift ( $ headers ) , $ matches ) ; $ code = $ matches [ 0 ] ; if ( is_numeric ( $ code ) ) { $ return -> code = ( int ) $ code ; } else { throw new JException ( 'Invalid server response.' , 0 , E_WARNING , $ this -> _response ) ; } foreach ( $ headers as $ header ) { $ pos = strpos ( $ header , ':' ) ; $ return -> headers [ trim ( substr ( $ header , 0 , $ pos ) ) ] = trim ( substr ( $ header , ( $ pos + 1 ) ) ) ; } if ( ! empty ( $ response [ 1 ] ) ) { $ return -> body = $ response [ 1 ] ; } return $ return ; }
Method to get a response object from a server response.
Method to get a response object from a server response .
// Create the response object. // Split the response into headers and body. // Get the response headers as an array. // Get the response code from the first offset of the response headers. // No valid response code was detected. // Add the response headers to the response object. // Set the response body if it exists.