Curl::process_response( string $response, array $options ): string|false

In this article

Process a response

Parameters

$responsestringrequired
Response data from the body
$optionsarrayrequired
Request options

Return

string|false HTTP response data including headers. False if non-blocking.

Source

	if ($options['blocking'] === false) {
		$fake_headers = '';
		$options['hooks']->dispatch('curl.after_request', [&$fake_headers]);
		return false;
	}

	if ($options['filename'] !== false && $this->stream_handle) {
		fclose($this->stream_handle);
		$this->headers = trim($this->headers);
	} else {
		$this->headers .= $response;
	}

	if (curl_errno($this->handle)) {
		$error = sprintf(
			'cURL error %s: %s',
			curl_errno($this->handle),
			curl_error($this->handle)
		);
		throw new Exception($error, 'curlerror', $this->handle);
	}

	$this->info = curl_getinfo($this->handle);

	$options['hooks']->dispatch('curl.after_request', [&$this->headers, &$this->info]);
	return $this->headers;
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.