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

Function request_passes_http_security

src/ui/http_server.c:3176–3199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3174}
3175
3176static bool request_passes_http_security(cbm_http_server_t *srv, cbm_http_conn_t *c,
3177 const cbm_http_req_t *req) {
3178 if (req->http_minor == 1 && req->host[0] == '\0') {
3179 cbm_http_replyf(c, 400, "", "%s", "{\"error\":\"Host header required\"}");
3180 return false;
3181 }
3182 if (req->host[0] != '\0' && !host_is_this_server(req->host, srv->port)) {
3183 cbm_http_replyf(c, 403, "", "%s", "{\"error\":\"forbidden host\"}");
3184 return false;
3185 }
3186 if (req->origin[0] != '\0' &&
3187 (req->host[0] == '\0' || !origin_is_same_server(req->origin, srv->port) ||
3188 !origin_matches_host(req->origin, req->host, srv->port))) {
3189 cbm_http_replyf(c, 403, "", "%s", "{\"error\":\"forbidden origin\"}");
3190 return false;
3191 }
3192 update_cors(req, srv->port);
3193 bool is_post = strcmp(req->method, "POST") == 0;
3194 if (route_is_protected(req->path) && is_post && !content_type_is_json(req->content_type)) {
3195 cbm_http_replyf(c, 415, g_cors_json, "%s", "{\"error\":\"application/json required\"}");
3196 return false;
3197 }
3198 return true;
3199}
3200
3201static void dispatch_request(cbm_http_server_t *srv, cbm_http_conn_t *c,
3202 const cbm_http_req_t *req) {

Callers 1

dispatch_requestFunction · 0.85

Calls 7

cbm_http_replyfFunction · 0.85
host_is_this_serverFunction · 0.85
origin_is_same_serverFunction · 0.85
origin_matches_hostFunction · 0.85
update_corsFunction · 0.85
route_is_protectedFunction · 0.85
content_type_is_jsonFunction · 0.85

Tested by

no test coverage detected