HttpResponse
Description
HTTP response under construction. Same allocator-ownership story as HttpRequest.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Http.c:38:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
HttpResponse response = HttpResponseInit(alloc_base);
Str body = StrInit(alloc_base);
StrWriteFmt(&body, "<h1>hi</h1>");- In
Http.c:382:
// ---------------------------------------------------------------------------
HttpResponse *HttpRespondWithHtml(HttpResponse *response, HttpResponseCode status, const Str *html) {
if (!response || !response->allocator || !html) {
LOG_FATAL("invalid arguments");- In
Http.c:394:
#if MISRA_HAVE_FILE
HttpResponse *HttpRespondWithFile(
HttpResponse *response,
HttpResponseCode status,- In
Http.c:395:
#if MISRA_HAVE_FILE
HttpResponse *HttpRespondWithFile(
HttpResponse *response,
HttpResponseCode status,
HttpContentType content_type,- In
Http.c:421:
#endif
Str HttpResponseSerialize(const HttpResponse *response, Allocator *alloc) {
Str out = StrInit(alloc);- In
Http.c:470:
}
void HttpResponseDeinit(HttpResponse *response) {
if (!response) {
LOG_FATAL("invalid arguments");- In
Http.h:247:
HttpHeaders headers;
Str body;
} HttpResponse;
#define HttpResponseInit(...) MISRA_OVERLOAD(HttpResponseInit, __VA_ARGS__)- In
Http.h:252:
#define HttpResponseInit_0() HttpResponseInit_1(MisraScope)
#define HttpResponseInit_1(alloc_ptr) \
((HttpResponse) {.allocator = ALLOCATOR_OF(alloc_ptr), \
.content_type = HTTP_CONTENT_TYPE_INVALID, \
.status_code = HTTP_RESPONSE_CODE_INVALID, \- In
Http.h:272:
/// FAILURE : Does not return - aborts on NULL arguments.
///
HttpResponse *HttpRespondWithHtml(HttpResponse *response, HttpResponseCode status, const Str *html);
#if MISRA_HAVE_FILE- In
Http.h:283:
/// FAILURE : Returns NULL on I/O or allocation failure.
///
HttpResponse *HttpRespondWithFile(
HttpResponse *response,
HttpResponseCode status,- In
Http.h:284:
///
HttpResponse *HttpRespondWithFile(
HttpResponse *response,
HttpResponseCode status,
HttpContentType content_type,- In
Http.h:301:
/// (unknown response code, unknown content type, etc.).
///
Str HttpResponseSerialize(const HttpResponse *response, Allocator *alloc);
///
- In
Http.h:306:
/// Release storage owned by `response` and zero the struct.
///
void HttpResponseDeinit(HttpResponse *response);
#endif // MISRA_PARSERS_HTTP_H
Last updated on