Commit 584cb1ac authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a function to (re)build a HTTP request or response into an sbuf.

Enable Id keyword


git-svn-id: http://www.varnish-cache.org/svn/trunk@120 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent aa0bb0d3
......@@ -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;
......
......@@ -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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment