Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
http server: added dump request trace
  • Loading branch information
perexg committed Oct 26, 2014
1 parent be8279c commit 16363a4
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/http.c
Expand Up @@ -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
Expand All @@ -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);

Expand Down Expand Up @@ -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'
*/
Expand Down

0 comments on commit 16363a4

Please sign in to comment.