chttpserver · Section 3
chttpsvr_req_stream_error
NAME
chttpsvr_req_stream_error - report why the last chttpsvr_req_read call failed
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/chttpserver.h> ccol_retval chttpsvr_req_stream_error(const chttpsvr_req *req);
DESCRIPTION
Tells you why the last chttpsvr_req_read call on req returned -1. The result means something only right after such a -1, and at any other time it is unspecified. It reports only the real transfer errors of chttpsvr_req_read, the ones that depend on the data (see chttpsvr_req_read(3)). When the -1 came from misuse by the caller, it reports ccol_success, which you can't tell apart from "no error". There are two such misuses: A NULL buf with a buflen above 0, and a request whose route was not registered with chttpsvr_register_streaming_handler. Both are plain programming errors that happen on every call of the faulty code, so you are expected to find and fix them in ordinary testing instead of diagnosing them at run time.
RETURN VALUE
ccol_timed_out; stream_read_timeout_us expired while the handler waited for the next batch, or the request spent more than max_body_read_duration_us reading its body (when that field is set), or the average rate of the body fell below min_transfer_rate_bps after the grace period. ccol_msg_too_large; the body passed max_body_size in the middle of the stream, or one chunk of a chunked Transfer-Encoding declared a size above max_body_size before the server read any data of it. ccol_not_enough_memory; an internal allocation failed while the server grew the body buffer. The client did not cause this. ccol_http_transfer_aborted; the connection was closed or reset, or the framing of the body was malformed. ccol_success; no error is on record for req, or the -1 came from one of the misuses above. ccol_invalid_args; req is NULL, or it names no request.
SEE ALSO
chttpsvr_req_read(3), chttpsvr_register_streaming_handler(3)