void HTTP_Init(void);
void http_CopyHttp(struct http *to, struct http *fm);
void http_Write(struct worker *w, struct http *hp, int resp);
+void http_GetReq(int fd, struct http *to, struct http *fm);
void http_CopyReq(int fd, struct http *to, struct http *fm);
void http_CopyResp(int fd, struct http *to, struct http *fm);
void http_FilterHeader(int fd, struct http *to, struct http *fm, unsigned how);
i &= ~O_NONBLOCK;
i = fcntl(fd, F_SETFL, i);
- while (cl != 0) {
+ while (cl > 0) {
i = http_Read(hp, fd, p, cl);
assert(i > 0); /* XXX seen */
p += i;
assert(vc != NULL); /* XXX: handle this */
VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
- http_CopyReq(vc->fd, vc->http, sp->http);
+ http_GetReq(vc->fd, vc->http, sp->http);
http_FilterHeader(vc->fd, vc->http, sp->http, HTTPH_R_FETCH);
http_PrintfHeader(vc->fd, vc->http, "X-Varnish: %u", sp->xid);
/*--------------------------------------------------------------------*/
+static void
+http_seth(int fd, struct http *to, unsigned n, enum shmlogtag tag, const char *fm)
+{
+ assert(n < MAX_HTTP_HDRS);
+ assert(fm != NULL);
+ to->hd[n].b = (void*)(uintptr_t)fm;
+ to->hd[n].e = strchr(fm, '\0');
+ VSLH(tag, fd, to, n);
+}
+
static void
http_copyh(int fd, struct http *to, struct http *fm, unsigned n, enum shmlogtag tag)
{
VSLH(tag, fd, to, n);
}
+void
+http_GetReq(int fd, struct http *to, struct http *fm)
+{
+
+ CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
+ CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
+ http_seth(fd, to, HTTP_HDR_REQ, SLT_Request, "GET");
+ http_copyh(fd, to, fm, HTTP_HDR_URL, SLT_URL);
+ http_seth(fd, to, HTTP_HDR_PROTO, SLT_Protocol, "HTTP/1.1");
+}
+
void
http_CopyReq(int fd, struct http *to, struct http *fm)
{