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

Function cbm_http_reply_buf

src/ui/httpd.c:740–762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 4

serve_embeddedFunction · 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