chttpclient · Section 3
chttpcli_async_result_get
NAME
chttpcli_async_result_get - block until the future of an async request is fulfilled, then give its typed result
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/chttpclient.h> chttpcli_async_result *chttpcli_async_result_get(cthrpool_future *f);
DESCRIPTION
This is a thin wrapper over cthrpool_future_get that casts its void*
result to chttpcli_async_result*. As with cthrpool_future_get, you can
call it more than once on the same future: Every later call returns the
same result pointer. Freeing the future does not free the result; free
it once with chttpcli_async_result_free.
The result has two public fields:
- rv holds the code that chttpcli_do would return for the same
request.
- resp is not NULL only when rv == ccol_success. The caller then owns
resp and frees it with chttpcli_resp_free before calling
chttpcli_async_result_free.
A successful request from chttpcli_do_async_streaming fills resp as
well, and its status_code means the same thing. resp->body is NULL,
resp->body_len is 0 and resp->headers is NULL there, though, because
the write callback received the body and the client keeps no headers.
PARAMETERS
f The future from chttpcli_do_async or from chttpcli_do_async_streaming.
RETURN VALUE
The result, or NULL if f is NULL or the future was cancelled before it was fulfilled.
SEE ALSO
chttpcli_do_async(3), chttpcli_do_async_streaming(3), chttpcli_async_result_free(3), cthrpool_future_get(3)