HttpRespondWithHtml
Description
Populate response as an HTML reply. The body is a deep copy of html allocated through response->allocator.
Success
Returns response with status_code, content_type, and body updated.
Failure
Does not return - aborts on NULL arguments.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Http.c:408:
// ---------------------------------------------------------------------------
HttpResponse *HttpRespondWithHtml(HttpResponse *response, HttpResponseCode status, const Str *html) {
if (!response || !response->allocator || !html) {
LOG_FATAL("invalid arguments");- In
Http.Leak.c:116:
HttpResponse response = HttpResponseInit(adbg);
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &first);
Str second = StrInit(adbg);- In
Http.Leak.c:121:
StrAppendFmt(&second, "<h1>second-body-also-long-enough-to-heap</h1>");
// Second call must free the first body before installing the second.
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &second);
StrDeinit(&first);- In
Http.Leak.c:152:
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);- In
Http.c:44:
Str body = StrInit(alloc_base);
StrAppendFmt(&body, "<h1>hi</h1>");
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &body);
StrDeinit(&body);
Last updated on