public function process_response()

in Aliyun/Log/requestcore.class.php [761:805]


	public function process_response($curl_handle = null, $response = null)
	{
        if ($response)
        {
            $this->response = $response;
        }
		// As long as this came back as a valid resource...

		if ($this->isCurlResource($curl_handle))
		{
			// Determine what's what.
			$header_size = curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE);
			$this->response_headers = substr($this->response, 0, $header_size);
			$this->response_body = substr($this->response, $header_size);
			$this->response_code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
			$this->response_info = curl_getinfo($curl_handle);

			// Parse out the headers
			$this->response_headers = explode("\r\n\r\n", trim($this->response_headers));
			$this->response_headers = array_pop($this->response_headers);
			$this->response_headers = explode("\r\n", $this->response_headers);
			array_shift($this->response_headers);

			// Loop through and split up the headers.
			$header_assoc = array();
			foreach ($this->response_headers as $header)
			{
				$kv = explode(': ', $header);
				$header_assoc[strtolower($kv[0])] = isset($kv[1])?$kv[1]:'';
			}

			// Reset the headers to the appropriate property.
			$this->response_headers = $header_assoc;
			$this->response_headers['_info'] = $this->response_info;
			$this->response_headers['_info']['method'] = $this->method;

			if ($curl_handle && $this->response)
			{
				return new $this->response_class($this->response_headers, $this->response_body, $this->response_code, $curl_handle);
			}
		}

		// Return false
		return false;
	}