From: phk Date: Tue, 18 Jul 2006 09:02:56 +0000 (+0000) Subject: Retire the http_GetReq(), http_GetURL() and http_GetProto() accessor X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d353a9cbb9878f5cbeace648a9c63140b093572c;p=varnish Retire the http_GetReq(), http_GetURL() and http_GetProto() accessor functions now that struct http is out of the closet. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@483 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 0d8b29d9..412072af 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -45,8 +45,8 @@ struct http { 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; @@ -267,12 +267,9 @@ void HSH_Init(void); 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); diff --git a/varnish-cache/bin/varnishd/cache_acceptor.c b/varnish-cache/bin/varnishd/cache_acceptor.c index 57a3ffbb..1d34afca 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.c +++ b/varnish-cache/bin/varnishd/cache_acceptor.c @@ -79,7 +79,6 @@ vca_write_obj(struct worker *w, struct sess *sp) { struct storage *st; unsigned u = 0; - char *r; uint64_t bytes = 0; @@ -93,14 +92,14 @@ vca_write_obj(struct worker *w, struct sess *sp) 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) { diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 76fa7820..8f2955a6 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -85,8 +85,7 @@ cnt_done(struct sess *sp) 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); diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index ca9adc97..c8249d8c 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -46,7 +46,7 @@ HSH_Lookup(struct sess *sp) struct http *h; struct objhead *oh; struct object *o; - char *b, *c; + char *c; assert(hash != NULL); w = sp->wrk; @@ -70,16 +70,15 @@ HSH_Lookup(struct sess *sp) 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)); @@ -98,7 +97,7 @@ HSH_Lookup(struct sess *sp) /* 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); diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index 7afefad8..25e960af 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -99,33 +99,6 @@ http_HdrIs(struct http *hp, const char *hdr, const char *val) 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) { diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 0d6f2bcd..29c8d27d 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -54,12 +54,10 @@ VRT_GetHdr(struct sess *sp, const char *n) 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); } /*--------------------------------------------------------------------*/