diff --git a/examples/http-server/main.c b/examples/http-server/main.c index c87b7e4b..20b652be 100644 --- a/examples/http-server/main.c +++ b/examples/http-server/main.c @@ -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; }