]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
http: optimize dump_request(), call it also for RTSP
authorJaroslav Kysela <perex@perex.cz>
Mon, 23 Mar 2015 14:52:17 +0000 (15:52 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 23 Mar 2015 14:52:17 +0000 (15:52 +0100)
src/http.c

index 715b69f5d7d6280a1a806b8363088e43bd2021f4..289c090d41dbfc39c08d7615e92169ee5c719e2d 100644 (file)
@@ -530,20 +530,21 @@ dump_request(http_connection_t *hc)
 {
   char buf[2048] = "";
   http_arg_t *ra;
-  int first;
+  int first, ptr = 0;
 
   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);
+    ptr += snprintf(buf + ptr, sizeof(buf) - ptr, 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);
+    ptr += snprintf(buf + ptr, sizeof(buf) - ptr, first ? "{{%s=%s" : ",%s=%s", ra->key, ra->val);
     first = 0;
   }
-  snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "}}");
+  if (!first)
+    ptr += snprintf(buf + ptr, sizeof(buf) - ptr, "}}");
 
   tvhtrace("http", "%s%s", hc->hc_url, buf);
 }
@@ -728,6 +729,7 @@ process_request(http_connection_t *hc, htsbuf_queue_t *spill)
 
   switch(hc->hc_version) {
   case RTSP_VERSION_1_0:
+    dump_request(hc);
     if (hc->hc_cseq)
       rval = hc->hc_process(hc, spill);
     else