]> err.no Git - varnish/commitdiff
Add a function to (re)build a HTTP request or response into an sbuf.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 6 Apr 2006 07:50:05 +0000 (07:50 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 6 Apr 2006 07:50:05 +0000 (07:50 +0000)
Enable Id keyword

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@120 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_httpd.c

index cc0742c63c523011afd053b7077a2c0878155eb2..5c306caa7a6a97434f4f03d3fb11b09287ea04e0 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 struct event_base;
+struct sbuf;
 
 #ifdef EV_TIMEOUT
 struct worker {
@@ -27,6 +28,7 @@ void VBE_ClosedFd(void *ptr);
 /* cache_httpd.c */
 void HttpdAnalyze(struct sess *sp, int rr);
 void HttpdGetHead(struct sess *sp, struct event_base *eb, sesscb_f *func);
+void HttpdBuildSbuf(int resp, int filter, struct sbuf *sb, struct sess *sp);
 
 /* cache_main.c */
 pthread_mutex_t        sessmtx;
index c8897a71af2c68ae8c3725e60e66a76a185d8389..b820455f0e6c6d9dae4c2ae27cba1ef55f6595e0 100644 (file)
@@ -12,6 +12,7 @@
 #include <pthread.h>
 #include <ctype.h>
 #include <event.h>
+#include <sbuf.h>
 
 #include "libvarnish.h"
 #include "shmlog.h"
@@ -181,3 +182,40 @@ HttpdGetHead(struct sess *sp, struct event_base *eb, sesscb_f *func)
         event_base_set(eb, sp->rd_e);
         event_add(sp->rd_e, NULL);      /* XXX: timeout */
 }
+
+/*--------------------------------------------------------------------*/
+
+void
+HttpdBuildSbuf(int resp, int filter, struct sbuf *sb, struct sess *sp)
+{
+
+       sbuf_clear(sb);
+       assert(sb != NULL);
+       if (resp) {
+               sbuf_cat(sb, sp->http.proto);
+               sbuf_cat(sb, " ");
+               sbuf_cat(sb, sp->http.status);
+               sbuf_cat(sb, " ");
+               sbuf_cat(sb, sp->http.response);
+       } else {
+               sbuf_cat(sb, sp->http.req);
+               sbuf_cat(sb, " ");
+               sbuf_cat(sb, sp->http.url);
+               sbuf_cat(sb, " ");
+               sbuf_cat(sb, sp->http.proto);
+       }
+       sbuf_cat(sb, "\r\n");
+#define HTTPH(a, b, c, d, e, f, g)                             \
+       do {                                                    \
+               if ((!filter || d) && sp->http.b != NULL) {     \
+                       sbuf_cat(sb, a ": ");                   \
+                       sbuf_cat(sb, sp->http.b);               \
+                       sbuf_cat(sb, "\r\n");                   \
+               }                                               \
+       } while (0);
+#include "http_headers.h"
+#undef HTTPH
+       sbuf_cat(sb, "\r\n");
+       sbuf_finish(sb);
+
+}