Show requests in flight

This commit is contained in:
Sergey Lyubka committed 2021-12-24 20:46:31 +00:00
1 parent 62411d039e
commit 137efe2233
1 file changed
+9 -1
+9 -1
View File
@@ -20,10 +20,18 @@ static void signal_handler(int signo) {
// Simply serve static files from `s_root_dir`
static void cb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = ev_data, tmp = {};
struct mg_str unknown = mg_str_n("?", 1), *cl;
struct mg_http_serve_opts opts = {0};
opts.root_dir = s_root_dir;
opts.ssi_pattern = s_ssi_pattern;
mg_http_serve_dir(c, ev_data, &opts);
mg_http_serve_dir(c, hm, &opts);
mg_http_parse((char *) c->send.buf, c->send.len, &tmp);
cl = mg_http_get_header(&tmp, "Content-Length");
if (cl == NULL) cl = &unknown;
LOG(LL_INFO, ("%.*s %.*s %.*s %.*s", (int) hm->method.len, hm->method.ptr,
(int) hm->uri.len, hm->uri.ptr, (int) tmp.uri.len,
tmp.uri.ptr, (int) cl->len, cl->ptr));
}
(void) fn_data;
}