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

Function cbm_http_reply_buf

src/ui/httpd.c:519–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519void cbm_http_reply_buf(cbm_http_conn_t *c, int status, const char *extra_headers, const void *data,
520 size_t len) {
521 if (!c)
522 return;
523 c->response_status = status;
524 c->response_bytes = len;
525 char head[1024];
526 int hn = snprintf(head, sizeof(head),
527 "HTTP/1.1 %d %s\r\n"
528 "%s"
529 "Content-Length: %zu\r\n"
530 "Connection: close\r\n"
531 "\r\n",
532 status, status_reason(status), extra_headers ? extra_headers : "", len);
533 if (hn < 0 || hn >= (int)sizeof(head))
534 return; /* oversized extra_headers — drop the response, conn closes */
535 if (send_all(c->fd, head, (size_t)hn) != 0)
536 return;
537 if (len > 0)
538 (void)send_all(c->fd, data, len);
539}
540
541void cbm_http_replyf(cbm_http_conn_t *c, int status, const char *extra_headers, const char *fmt,
542 ...) {

Callers 3

serve_embeddedFunction · 0.85
dispatch_requestFunction · 0.85
cbm_http_replyfFunction · 0.85

Calls 2

status_reasonFunction · 0.85
send_allFunction · 0.85

Tested by

no test coverage detected