From 16363a4ae32beb1742760c91a650dad977ba00b1 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 26 Oct 2014 18:26:01 +0100 Subject: [PATCH] http server: added dump request trace --- src/http.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/http.c b/src/http.c index b2e41ccb..8fc9ff47 100644 --- a/src/http.c +++ b/src/http.c @@ -603,6 +603,39 @@ http_process_request(http_connection_t *hc, htsbuf_queue_t *spill) } } +/* + * + */ +#if ENABLE_TRACE +static void +dump_request(http_connection_t *hc) +{ + char buf[2048] = ""; + http_arg_t *ra; + int first; + + first = 1; + TAILQ_FOREACH(ra, &hc->hc_req_args, link) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), first ? "?%s=%s" : "&%s=%s", ra->key, ra->val); + first = 0; + } + + first = 1; + TAILQ_FOREACH(ra, &hc->hc_args, link) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), first ? "{{%s=%s" : ",%s=%s", ra->key, ra->val); + first = 0; + } + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "}}"); + + tvhtrace("http", "%s%s", hc->hc_url, buf); +} +#else +static inline void +dump_request(http_connection_t *hc) +{ +} +#endif + /** * Process a request, extract info from headers, dispatch command and * clean up @@ -613,6 +646,8 @@ process_request(http_connection_t *hc, htsbuf_queue_t *spill) char *v, *argv[2]; int n, rval = -1; uint8_t authbuf[150]; + + dump_request(hc); hc->hc_url_orig = tvh_strdupa(hc->hc_url); @@ -717,7 +752,6 @@ http_arg_set(struct http_arg_list *list, const char *key, const char *val) ra->val = strdup(val); } - /* * Split a string in components delimited by 'delimiter' */