MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_http_reply_buf

Function cbm_http_reply_buf

src/ui/httpd.c:745–767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743}
744
745void cbm_http_reply_buf(cbm_http_conn_t *c, int status, const char *extra_headers, const void *data,
746 size_t len) {
747 if (!c)
748 return;
749 atomic_store_explicit(&c->response_started, true, memory_order_release);
750 c->response_status = status;
751 c->response_bytes = len;
752 char head[1024];
753 int hn = snprintf(head, sizeof(head),
754 "HTTP/1.1 %d %s\r\n"
755 "%s"
756 "Content-Length: %zu\r\n"
757 "Connection: close\r\n"
758 "\r\n",
759 status, status_reason(status), extra_headers ? extra_headers : "", len);
760 if (hn < 0 || hn >= (int)sizeof(head))
761 return; /* oversized extra_headers — drop the response, conn closes */
762 int64_t deadline = now_ms() + c->send_deadline_ms;
763 if (send_all(c, head, (size_t)hn, deadline) != 0)
764 return;
765 if (len > 0)
766 (void)send_all(c, data, len, deadline);
767}
768
769void cbm_http_replyf(cbm_http_conn_t *c, int status, const char *extra_headers, const char *fmt,
770 ...) {

Callers 6

serve_embeddedFunction · 0.85
handle_index_statusFunction · 0.85
handle_atlas_repositoryFunction · 0.85
dispatch_requestFunction · 0.85
cbm_http_replyfFunction · 0.85
th_httpd_large_replyFunction · 0.85

Calls 3

status_reasonFunction · 0.85
send_allFunction · 0.85
now_msFunction · 0.70

Tested by 1

th_httpd_large_replyFunction · 0.68