| 225 | #define CBM_UI_CSP "Content-Security-Policy: " CBM_UI_CSP_VALUE "\r\n" |
| 226 | |
| 227 | static bool serve_embedded(cbm_http_conn_t *c, const char *path) { |
| 228 | const cbm_embedded_file_t *f = cbm_embedded_lookup(path); |
| 229 | if (!f) |
| 230 | return false; |
| 231 | |
| 232 | /* Build headers with correct Content-Type for this asset */ |
| 233 | char hdrs[1024]; |
| 234 | snprintf(hdrs, sizeof(hdrs), |
| 235 | "%sContent-Type: %s\r\n" |
| 236 | "Cache-Control: public, max-age=31536000, immutable\r\n" |
| 237 | "X-Content-Type-Options: nosniff\r\n" CBM_UI_CSP, |
| 238 | g_cors, f->content_type); |
| 239 | |
| 240 | cbm_http_reply_buf(c, 200, hdrs, f->data, (size_t)f->size); |
| 241 | return true; |
| 242 | } |
| 243 | |
| 244 | /* Build DB path for a project: <cache_dir>/<project>.db */ |
| 245 | static void db_path_for_project(const char *project, char *buf, size_t bufsz) { |
no test coverage detected