HttpResponseSerialize
Description
Serialize response to its on-wire HTTP/1.1 form. Caller owns the returned Str and must deinit it. The result is exactly the bytes that should land on the transport (sockets / files / etc.) — no transport call is made.
Success
Returns a populated Str.
Failure
Returns an empty Str and logs the failing condition (unknown response code, unknown content type, etc.).
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Http.c:457:
if (!response) {
LOG_FATAL("HttpResponseSerialize: response is NULL");
}- In
Http.c:462:
Zstr response_code = HttpResponseCodeToZstr(response->status_code);
if (!response_code) {
LOG_ERROR("HttpResponseSerialize: invalid/unknown response code {}", (u32)response->status_code);
return out;
}- In
Http.c:467:
Zstr content_type = HttpContentTypeToZstr(response->content_type);
if (!content_type) {
LOG_ERROR("HttpResponseSerialize: invalid/unknown content type {}", (u32)response->content_type);
return out;
}- In
Http.c:489:
if (StrLen(&response->body)) {
if (!StrPushBackMany(&out, StrBegin(&response->body), StrLen(&response->body))) {
LOG_ERROR("HttpResponseSerialize: failed to append body");
StrDeinit(&out);
return StrInit(alloc);- In
Http.c:47:
StrDeinit(&body);
Str wire = HttpResponseSerialize(&response, alloc_base);
// Spot-check the wire format:
Last updated on