HttpResponseInit
Description
Initialize an empty HttpResponse. Inside a Scope the allocator argument may be omitted (uses MisraScope).
Success
Returns an HttpResponse with content_type and status_code set to their invalid sentinels, an empty headers Vec that takes ownership of inserted headers by move (freed per-element by HttpResponseDeinit), and an empty body.
Failure
Macro cannot fail (pure literal expansion).
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Http.c:43:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
HttpResponse response = HttpResponseInit(alloc_base);
Str body = StrInit(alloc_base);
StrAppendFmt(&body, "<h1>hi</h1>");- In
Http.c:221:
FileClose(&f);
HttpResponse response = HttpResponseInit(alloc_base);
HttpResponse *res =
HttpRespondWithFile(&response, HTTP_RESPONSE_CODE_OK, HTTP_CONTENT_TYPE_TEXT_PLAIN, StrBegin(&path));- In
Http.c:248:
FileClose(&f); // leave it empty
HttpResponse response = HttpResponseInit(alloc_base);
HttpResponse *res =
HttpRespondWithFile(&response, HTTP_RESPONSE_CODE_OK, HTTP_CONTENT_TYPE_TEXT_PLAIN, StrBegin(&path));- In
Http.c:269:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
HttpResponse response = HttpResponseInit(alloc_base);
HttpResponse *res = HttpRespondWithFile(
&response,- In
Http.c:353:
StrAppendFmt(&first, "<h1>first-body-long-enough-to-heap-allocate</h1>");
HttpResponse response = HttpResponseInit(adbg);
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &first);- In
Http.c:382:
Str first = StrInit(adbg);
StrAppendFmt(&first, "<h1>old-body-long-enough-to-force-heap-here</h1>");
HttpResponse response = HttpResponseInit(adbg);
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &first);
StrDeinit(&first);
Last updated on