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

Retire the http_GetReq(), http_GetURL() and http_GetProto() accessor

functions now that struct http is out of the closet.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@483 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent d8fee03f
...@@ -45,8 +45,8 @@ struct http { ...@@ -45,8 +45,8 @@ struct http {
char *s; /* start of buffer */ char *s; /* start of buffer */
char *t; /* start of trailing data */ char *t; /* start of trailing data */
char *v; /* end of valid bytes */
char *e; /* end of buffer */ char *e; /* end of buffer */
char *v; /* valid bytes */
char *req; char *req;
char *url; char *url;
...@@ -267,12 +267,9 @@ void HSH_Init(void); ...@@ -267,12 +267,9 @@ void HSH_Init(void);
void http_Init(struct http *ht, void *space); void http_Init(struct http *ht, void *space);
int http_GetHdr(struct http *hp, const char *hdr, char **ptr); 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_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_GetStatus(struct http *hp);
int http_HdrIs(struct http *hp, const char *hdr, const char *val); 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_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); 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_DissectRequest(struct http *sp, int fd);
int http_DissectResponse(struct http *sp, int fd); int http_DissectResponse(struct http *sp, int fd);
......
...@@ -79,7 +79,6 @@ vca_write_obj(struct worker *w, struct sess *sp) ...@@ -79,7 +79,6 @@ vca_write_obj(struct worker *w, struct sess *sp)
{ {
struct storage *st; struct storage *st;
unsigned u = 0; unsigned u = 0;
char *r;
uint64_t bytes = 0; uint64_t bytes = 0;
...@@ -93,14 +92,14 @@ vca_write_obj(struct worker *w, struct sess *sp) ...@@ -93,14 +92,14 @@ vca_write_obj(struct worker *w, struct sess *sp)
sp->obj->age + sp->t_req - sp->obj->entered); sp->obj->age + sp->t_req - sp->obj->entered);
sbuf_printf(w->sb, "Via: 1.1 varnish\r\n"); sbuf_printf(w->sb, "Via: 1.1 varnish\r\n");
sbuf_printf(w->sb, "X-Varnish: xid %u\r\n", sp->obj->xid); 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, "Connection: close\r\n");
sbuf_printf(w->sb, "\r\n"); sbuf_printf(w->sb, "\r\n");
sbuf_finish(w->sb); sbuf_finish(w->sb);
vca_write(sp, sbuf_data(w->sb), sbuf_len(w->sb)); vca_write(sp, sbuf_data(w->sb), sbuf_len(w->sb));
bytes += sbuf_len(w->sb); bytes += sbuf_len(w->sb);
assert(http_GetReq(sp->http, &r)); /* XXX: conditional request handling */
if (!strcmp(r, "GET")) { if (!strcmp(sp->http->req, "GET")) {
TAILQ_FOREACH(st, &sp->obj->store, list) { TAILQ_FOREACH(st, &sp->obj->store, list) {
u += st->len; u += st->len;
if (st->stevedore->send == NULL) { if (st->stevedore->send == NULL) {
......
...@@ -85,8 +85,7 @@ cnt_done(struct sess *sp) ...@@ -85,8 +85,7 @@ cnt_done(struct sess *sp)
if (http_GetHdr(sp->http, "Connection", &b) && if (http_GetHdr(sp->http, "Connection", &b) &&
!strcmp(b, "close")) { !strcmp(b, "close")) {
vca_close_session(sp, "Connection header"); vca_close_session(sp, "Connection header");
} else if (http_GetProto(sp->http, &b) && } else if (strcmp(sp->http->proto, "HTTP/1.1")) {
strcmp(b, "HTTP/1.1")) {
vca_close_session(sp, "not HTTP/1.1"); vca_close_session(sp, "not HTTP/1.1");
} }
VCL_Rel(sp->vcl); VCL_Rel(sp->vcl);
......
...@@ -46,7 +46,7 @@ HSH_Lookup(struct sess *sp) ...@@ -46,7 +46,7 @@ HSH_Lookup(struct sess *sp)
struct http *h; struct http *h;
struct objhead *oh; struct objhead *oh;
struct object *o; struct object *o;
char *b, *c; char *c;
assert(hash != NULL); assert(hash != NULL);
w = sp->wrk; w = sp->wrk;
...@@ -70,16 +70,15 @@ HSH_Lookup(struct sess *sp) ...@@ -70,16 +70,15 @@ HSH_Lookup(struct sess *sp)
VSL_stats->n_object++; VSL_stats->n_object++;
} }
assert(http_GetURL(h, &b));
if (!http_GetHdr(h, "Host", &c)) if (!http_GetHdr(h, "Host", &c))
c = b; c = h->url;
if (sp->obj != NULL) { if (sp->obj != NULL) {
o = sp->obj; o = sp->obj;
oh = o->objhead; oh = o->objhead;
AZ(pthread_mutex_lock(&oh->mtx)); AZ(pthread_mutex_lock(&oh->mtx));
goto were_back; goto were_back;
} }
oh = hash->lookup(b, c, w->nobjhead); oh = hash->lookup(h->url, c, w->nobjhead);
if (oh == w->nobjhead) if (oh == w->nobjhead)
w->nobjhead = NULL; w->nobjhead = NULL;
AZ(pthread_mutex_lock(&oh->mtx)); AZ(pthread_mutex_lock(&oh->mtx));
...@@ -98,7 +97,7 @@ HSH_Lookup(struct sess *sp) ...@@ -98,7 +97,7 @@ HSH_Lookup(struct sess *sp)
/* ignore */ /* ignore */
} else if (o->ttl == 0) { } else if (o->ttl == 0) {
/* Object banned but not reaped yet */ /* Object banned but not reaped yet */
} else if (BAN_CheckObject(o, b)) { } else if (BAN_CheckObject(o, h->url)) {
o->ttl = 0; o->ttl = 0;
VSL(SLT_ExpBan, 0, "%u was banned", o->xid); VSL(SLT_ExpBan, 0, "%u was banned", o->xid);
EXP_TTLchange(o); EXP_TTLchange(o);
......
...@@ -99,33 +99,6 @@ http_HdrIs(struct http *hp, const char *hdr, const char *val) ...@@ -99,33 +99,6 @@ http_HdrIs(struct http *hp, const char *hdr, const char *val)
return (0); 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 int
http_GetTail(struct http *hp, unsigned len, char **b, char **e) http_GetTail(struct http *hp, unsigned len, char **b, char **e)
{ {
......
...@@ -54,12 +54,10 @@ VRT_GetHdr(struct sess *sp, const char *n) ...@@ -54,12 +54,10 @@ VRT_GetHdr(struct sess *sp, const char *n)
char * char *
VRT_GetReq(struct sess *sp) VRT_GetReq(struct sess *sp)
{ {
char *p;
assert(sp != NULL); assert(sp != NULL);
assert(sp->http != NULL); assert(sp->http != NULL);
assert(http_GetReq(sp->http, &p)); return (sp->http->req);
return (p);
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
......
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