phasync
CurlAwaiter / await

Method

CurlAwaiter::await

Runs $ch to completion and returns its body, without blocking other coroutines.

Description#

public static CurlAwaiter::await(
    CurlHandle $ch
): mixed

Returns the response body, set CURLOPT_RETURNTRANSFER to get one: without it curl writes the body to output and this returns false. A failed transfer does not throw and returns an empty string: check curl_errno($ch). Must be called from a coroutine. A cancelled coroutine removes its handle from the multi handle.

Parameters#

$ch CurlHandle
An initialized handle with its options set

Return values#

mixed

Errors / Exceptions#

ExceptionWhen
RuntimeExceptionIf the handle cannot be added to the multi handle