Commit f059e77a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add vca_write_obj() which writes an sbuf (as) HTTP header and the

object from the sessions to the client.


git-svn-id: http://www.varnish-cache.org/svn/trunk@185 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent da216f85
......@@ -59,6 +59,7 @@ extern struct stevedore *stevedore;
/* cache_acceptor.c */
void vca_write(struct sess *sp, void *ptr, size_t len);
void vca_write_obj(struct sess *sp, struct sbuf *hdr);
void vca_flush(struct sess *sp);
void vca_return_session(struct sess *sp);
void vca_close_session(struct sess *sp, const char *why);
......
......@@ -84,6 +84,21 @@ vca_write(struct sess *sp, void *ptr, size_t len)
sp->mem->liov += len;
}
void
vca_write_obj(struct sess *sp, struct sbuf *hdr)
{
struct storage *st;
vca_write(sp, sbuf_data(hdr), sbuf_len(hdr));
TAILQ_FOREACH(st, &sp->obj->store, list) {
if (st->stevedore->send != NULL)
st->stevedore->send(st, sp);
else
vca_write(sp, st->ptr, st->len);
}
vca_flush(sp);
}
/*--------------------------------------------------------------------*/
static void
......
......@@ -60,9 +60,8 @@ fetch_straight(struct worker *w, struct sess *sp, int fd, struct http *hp, char
}
http_BuildSbuf(2, w->sb, hp);
vca_write(sp, sbuf_data(w->sb), sbuf_len(w->sb));
vca_write(sp, st->ptr, st->len);
vca_flush(sp);
vca_write_obj(sp, w->sb);
hash->deref(sp->obj);
return (0);
......@@ -126,11 +125,8 @@ fetch_chunked(struct worker *w, struct sess *sp, int fd, struct http *hp)
}
http_BuildSbuf(2, w->sb, hp);
vca_write(sp, sbuf_data(w->sb), sbuf_len(w->sb));
TAILQ_FOREACH(st, &sp->obj->store, list)
vca_write(sp, st->ptr, st->len);
vca_flush(sp);
vca_write_obj(sp, w->sb);
hash->deref(sp->obj);
......
......@@ -68,23 +68,15 @@ LookupSession(struct worker *w, struct sess *sp)
static int
DeliverSession(struct worker *w, struct sess *sp)
{
char buf[BUFSIZ];
struct storage *st;
sprintf(buf,
sbuf_clear(w->sb);
sbuf_printf(w->sb,
"HTTP/1.1 200 OK\r\n"
"Server: Varnish\r\n"
"Content-Length: %u\r\n"
"\r\n", sp->obj->len);
vca_write(sp, buf, strlen(buf));
TAILQ_FOREACH(st, &sp->obj->store, list) {
if (st->stevedore->send != NULL)
st->stevedore->send(st, sp);
else
vca_write(sp, st->ptr, st->len);
}
vca_flush(sp);
vca_write_obj(sp, w->sb);
return (1);
}
......
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