]> err.no Git - varnish/commitdiff
Retire the http_GetReq(), http_GetURL() and http_GetProto() accessor
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 18 Jul 2006 09:02:56 +0000 (09:02 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 18 Jul 2006 09:02:56 +0000 (09:02 +0000)
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

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_acceptor.c
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/cache_http.c
varnish-cache/bin/varnishd/cache_vrt.c

index 0d8b29d9a4a64043a5e143185718a79a692190a5..412072afde0a3ee22aac99fddecc80d577a74a94 100644 (file)
@@ -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);
index 57a3ffbb255596398a94f9c945025f9038d52258..1d34afcaef666ec558a6d270073755800429c06c 100644 (file)
@@ -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) {
index 76fa7820be9287797724921019054471dcfa25bd..8f2955a688f4d9256693af3d6da0cf242a0cca0f 100644 (file)
@@ -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);
index ca9adc971b92e405a3adb4f46b9251d595113a42..c8249d8cb5362db071603754d48f6cb2217c91d4 100644 (file)
@@ -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);
index 7afefad86012eaf74644d297b280a91b1ed61c1c..25e960af3b848d4a28831cb5ef6a3b79ae753777 100644 (file)
@@ -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)
 {
index 0d6f2bcd3448a14cb11732f74cb42343927abb76..29c8d27d2e4c6658136ca9af7936d4bbf914cfcd 100644 (file)
@@ -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);
 }
 
 /*--------------------------------------------------------------------*/