HttpResponse
Description
HTTP response under construction. Same allocator-ownership story as HttpRequest.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Http.h:294:
HttpHeaders headers;
Str body;
} HttpResponse;
///
- In
Http.h:312:
#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:342:
/// TAGS: Http, Respond, Html
///
HttpResponse *HttpRespondWithHtml(HttpResponse *response, HttpResponseCode status, const Str *html);
#if FEATURE_FILE- In
Http.h:388:
/// TAGS: Http, Response, Deinit, Init
///
void HttpResponseDeinit(HttpResponse *response);
#endif // MISRA_PARSERS_HTTP_H
- In
Http.c:408:
// ---------------------------------------------------------------------------
HttpResponse *HttpRespondWithHtml(HttpResponse *response, HttpResponseCode status, const Str *html) {
if (!response || !response->allocator || !html) {
LOG_FATAL("invalid arguments");- In
Http.c:420:
#if FEATURE_FILE
HttpResponse *http_respond_with_file_zstr(
HttpResponse *response,
HttpResponseCode status,- In
Http.c:421:
#if FEATURE_FILE
HttpResponse *http_respond_with_file_zstr(
HttpResponse *response,
HttpResponseCode status,
HttpContentType content_type,- In
Http.c:440:
}
HttpResponse *http_respond_with_file_str(
HttpResponse *response,
HttpResponseCode status,- In
Http.c:441:
HttpResponse *http_respond_with_file_str(
HttpResponse *response,
HttpResponseCode status,
HttpContentType content_type,- In
Http.c:453:
#endif
Str http_response_serialize(const HttpResponse *response, Allocator *alloc) {
Str out = StrInit(alloc);- In
Http.c:497:
}
void HttpResponseDeinit(HttpResponse *response) {
if (!response) {
LOG_FATAL("invalid arguments");- In
Http.Leak.c:115:
StrAppendFmt(&first, "<h1>first-body-long-enough-to-heap-allocate</h1>");
HttpResponse response = HttpResponseInit(adbg);
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &first);- In
Http.Leak.c:151:
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);- In
Http.Leak.c:164:
// Serving the file must free the old (HTML) body before installing the new.
HttpResponse *res =
HttpRespondWithFile(&response, HTTP_RESPONSE_CODE_OK, HTTP_CONTENT_TYPE_TEXT_PLAIN, StrBegin(&path));
ok = ok && (res != NULL);- In
Http.c:41:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
HttpResponse response = HttpResponseInit(alloc_base);
Str body = StrInit(alloc_base);
StrAppendFmt(&body, "<h1>hi</h1>");- In
Http.c:219:
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:220:
HttpResponse response = HttpResponseInit(alloc_base);
HttpResponse *res =
HttpRespondWithFile(&response, HTTP_RESPONSE_CODE_OK, HTTP_CONTENT_TYPE_TEXT_PLAIN, StrBegin(&path));- In
Http.c:246:
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:247:
HttpResponse response = HttpResponseInit(alloc_base);
HttpResponse *res =
HttpRespondWithFile(&response, HTTP_RESPONSE_CODE_OK, HTTP_CONTENT_TYPE_TEXT_PLAIN, StrBegin(&path));- In
Http.c:267:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
HttpResponse response = HttpResponseInit(alloc_base);
HttpResponse *res = HttpRespondWithFile(
&response,- In
Http.c:268:
HttpResponse response = HttpResponseInit(alloc_base);
HttpResponse *res = HttpRespondWithFile(
&response,
HTTP_RESPONSE_CODE_OK,
Last updated on