static int
cnt_fetch(struct sess *sp)
{
+ struct bereq *bereq;
+ struct http *hp;
+ char *b;
+ int i;
+
+ bereq = vbe_new_bereq();
+ AN(bereq);
+ hp = bereq->http;
+ hp->logtag = HTTP_Tx;
+
+ http_GetReq(sp->wrk, sp->fd, hp, sp->http);
+ http_FilterHeader(sp->wrk, sp->fd, hp, sp->http, HTTPH_R_FETCH);
+ http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid);
+ http_PrintfHeader(sp->wrk, sp->fd, hp,
+ "X-Forwarded-for: %s", sp->addr);
+ if (!http_GetHdr(hp, H_Host, &b)) {
+ http_PrintfHeader(sp->wrk, sp->fd, hp, "Host: %s",
+ sp->backend->hostname);
+ }
+ sp->bereq = bereq;
+
+ i = Fetch(sp);
+ vbe_free_bereq(sp->bereq);
+ sp->bereq = NULL;
- if (Fetch(sp)) {
+ if (i) {
SYN_ErrorPage(sp, 503, "Error talking to backend", 30);
} else {
RFC2616_cache_policy(sp, &sp->obj->http); /* XXX -> VCL */
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
assert(sp->obj->busy != 0);
w = sp->wrk;
+ bereq = sp->bereq;
+ hp = bereq->http;
sp->obj->xid = sp->xid;
vc = VBE_GetFd(sp);
if (vc == NULL)
return (1);
-
- bereq = vbe_new_bereq();
- AN(bereq);
- hp = bereq->http;
- hp->logtag = HTTP_Tx;
-
- http_GetReq(w, vc->fd, hp, sp->http);
- http_FilterHeader(w, vc->fd, hp, sp->http, HTTPH_R_FETCH);
- http_PrintfHeader(w, vc->fd, hp, "X-Varnish: %u", sp->xid);
- http_PrintfHeader(w, vc->fd, hp,
- "X-Forwarded-for: %s", sp->addr);
- if (!http_GetHdr(hp, H_Host, &b)) {
- http_PrintfHeader(w, vc->fd, hp, "Host: %s",
- sp->backend->hostname);
- }
-
WRK_Reset(w, &vc->fd);
http_Write(w, hp, 0);
if (WRK_Flush(w)) {
/* XXX: cleanup */
+
return (1);
}
VBE_ClosedFd(sp->wrk, vc, 0);
else
VBE_RecycleFd(sp->wrk, vc);
- vbe_free_bereq(bereq);
return (0);
}