char *s; /* start of buffer */
char *t; /* start of trailing data */
+ char *v; /* end of valid bytes */
char *e; /* end of buffer */
- char *v; /* valid bytes */
char *req;
char *url;
void http_Init(struct http *ht, void *space);
int http_GetHdr(struct http *hp, const char *hdr, char **ptr);
int http_GetHdrField(struct http *hp, const char *hdr, const char *field, char **ptr);
-int http_GetReq(struct http *hp, char **b);
-int http_GetProto(struct http *hp, char **b);
int http_GetStatus(struct http *hp);
int http_HdrIs(struct http *hp, const char *hdr, const char *val);
int http_GetTail(struct http *hp, unsigned len, char **b, char **e);
-int http_GetURL(struct http *hp, char **b);
void http_RecvHead(struct http *hp, int fd, struct event_base *eb, http_callback_f *func, void *arg);
int http_DissectRequest(struct http *sp, int fd);
int http_DissectResponse(struct http *sp, int fd);
{
struct storage *st;
unsigned u = 0;
- char *r;
uint64_t bytes = 0;
sp->obj->age + sp->t_req - sp->obj->entered);
sbuf_printf(w->sb, "Via: 1.1 varnish\r\n");
sbuf_printf(w->sb, "X-Varnish: xid %u\r\n", sp->obj->xid);
- if (http_GetProto(sp->http, &r) && strcmp(r, "HTTP/1.1"))
+ if (strcmp(sp->http->proto, "HTTP/1.1"))
sbuf_printf(w->sb, "Connection: close\r\n");
sbuf_printf(w->sb, "\r\n");
sbuf_finish(w->sb);
vca_write(sp, sbuf_data(w->sb), sbuf_len(w->sb));
bytes += sbuf_len(w->sb);
- assert(http_GetReq(sp->http, &r));
- if (!strcmp(r, "GET")) {
+ /* XXX: conditional request handling */
+ if (!strcmp(sp->http->req, "GET")) {
TAILQ_FOREACH(st, &sp->obj->store, list) {
u += st->len;
if (st->stevedore->send == NULL) {
if (http_GetHdr(sp->http, "Connection", &b) &&
!strcmp(b, "close")) {
vca_close_session(sp, "Connection header");
- } else if (http_GetProto(sp->http, &b) &&
- strcmp(b, "HTTP/1.1")) {
+ } else if (strcmp(sp->http->proto, "HTTP/1.1")) {
vca_close_session(sp, "not HTTP/1.1");
}
VCL_Rel(sp->vcl);
struct http *h;
struct objhead *oh;
struct object *o;
- char *b, *c;
+ char *c;
assert(hash != NULL);
w = sp->wrk;
VSL_stats->n_object++;
}
- assert(http_GetURL(h, &b));
if (!http_GetHdr(h, "Host", &c))
- c = b;
+ c = h->url;
if (sp->obj != NULL) {
o = sp->obj;
oh = o->objhead;
AZ(pthread_mutex_lock(&oh->mtx));
goto were_back;
}
- oh = hash->lookup(b, c, w->nobjhead);
+ oh = hash->lookup(h->url, c, w->nobjhead);
if (oh == w->nobjhead)
w->nobjhead = NULL;
AZ(pthread_mutex_lock(&oh->mtx));
/* ignore */
} else if (o->ttl == 0) {
/* Object banned but not reaped yet */
- } else if (BAN_CheckObject(o, b)) {
+ } else if (BAN_CheckObject(o, h->url)) {
o->ttl = 0;
VSL(SLT_ExpBan, 0, "%u was banned", o->xid);
EXP_TTLchange(o);
return (0);
}
-int
-http_GetReq(struct http *hp, char **b)
-{
- if (hp->req == NULL)
- return (0);
- *b = hp->req;
- return (1);
-}
-
-int
-http_GetURL(struct http *hp, char **b)
-{
- if (hp->url == NULL)
- return (0);
- *b = hp->url;
- return (1);
-}
-
-int
-http_GetProto(struct http *hp, char **b)
-{
- if (hp->proto == NULL)
- return (0);
- *b = hp->proto;
- return (1);
-}
-
int
http_GetTail(struct http *hp, unsigned len, char **b, char **e)
{
char *
VRT_GetReq(struct sess *sp)
{
- char *p;
assert(sp != NULL);
assert(sp->http != NULL);
- assert(http_GetReq(sp->http, &p));
- return (p);
+ return (sp->http->req);
}
/*--------------------------------------------------------------------*/