]> mj.ucw.cz Git - netgrind.git/commitdiff
Added content-type to HTTP dump.
authorMartin Mares <mj@ucw.cz>
Fri, 20 Jun 2003 12:08:39 +0000 (12:08 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 20 Jun 2003 12:08:39 +0000 (12:08 +0000)
netgrind/http.c

index b90c89382d7650447543b08c0b4a5edcf1bed6df..b329170eca3c88939557612b27ea1e330af3e87b 100644 (file)
@@ -189,17 +189,21 @@ static void http_report(struct flow *f, struct http_state *s, u64 when, byte *re
   format_timestamp(stamp, s->req_start_time);
   u64 ttotal = when - s->req_start_time;
   u64 tresp = (s->resp_line ? (s->resp_start_time - s->req_start_time) : 0);
+  byte *ctype = (http_lookup_hdr(&s->resp_headers, "Content-type:") ? : http_lookup_hdr(&s->req_headers, "Content-type:")) ? : (byte*)"-";
+  byte *sep;
+  if (sep = strchr(ctype, ';'))
+    *sep = 0;
   if (!http_counter++)
-    printf("# timestamp             source                destination           forwarded-for   res cac que   length total time  wait time method URL\n");
-         /* 2003-06-06 22:53:38.642 81.27.194.19:1175     205.217.153.53:80     123.123.123.123 200 ...   0    14030      0.957      0.444 GET http://... */
-  printf("%s %-21s %-21s %-15s %-3s %c%c%c %3d %8d %6d.%03d %6d.%03d %s %s\n",
+    printf("# timestamp             source                destination           forwarded-for   res cac que   length total time  wait time ctype      method URL\n");
+         /* 2003-06-06 22:53:38.642 81.27.194.19:1175     205.217.153.53:80     123.123.123.123 200 ...   0    14030      0.957      0.444 text/plain GET http://... */
+  printf("%s %-21s %-21s %-15s %-3s %c%c%c %3d %8d %6d.%03d %6d.%03d %-12s %s %s\n",
         stamp, src, dst, (ffor ? : "-"), reason,
         rq_cflag, rp_cflag, rp_hit,
         s->req_counter,
         s->body_total_size,
         (uns)(ttotal/1000000), (uns)(ttotal%1000000)/1000,
         (uns)(tresp/1000000), (uns)(tresp%1000000)/1000,
-        method, url);
+        ctype, method, url);
 
   s->req_counter++;
 }