]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] move the response headers to the http_req
authorWilly Tarreau <w@1wt.eu>
Sun, 21 Jan 2007 19:49:31 +0000 (20:49 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 21 Jan 2007 19:49:31 +0000 (20:49 +0100)
include/types/session.h
src/client.c
src/log.c
src/proto_http.c
src/session.c

index 1edc2f8544af27c4dea8f8a3994efde951a06589..bbb0ebe072fb6ae3e2190418259e577c9d562565 100644 (file)
@@ -139,7 +139,7 @@ struct http_msg {
        int sor;                        /* Start Of Request, relative to buffer */
        int col, sov;                   /* current header: colon, start of value */
        int eoh;                        /* End Of Headers, relative to buffer */
-       char **cap;                     /* array of captured request headers (may be NULL) */
+       char **cap;                     /* array of captured headers (may be NULL) */
        union {                         /* useful start line pointers, relative to buffer */
                struct {
                        int l;          /* request line length (not including CR) */
@@ -187,7 +187,6 @@ struct session {
        struct sockaddr_in srv_addr;            /* the address to connect to */
        struct server *srv;                     /* the server being used */
        struct pendconn *pend_pos;              /* if not NULL, points to the position in the pending queue */
-       char **rsp_cap;                         /* array of captured response headers (may be NULL) */
        struct http_req hreq;                   /* current HTTP request being processed. Should become a list. */
        struct {
                int logwait;                    /* log fields waiting to be collected : LW_* */
index 8bcd1431b2a1660028146fcb02604c50161503fc..e4babba0813450174e189f46e49910b0da16c884 100644 (file)
@@ -198,9 +198,9 @@ int event_accept(int fd) {
                s->uniq_id = totalconn;
                p->cum_feconn++;        /* cum_beconn will be increased once assigned */
 
-               s->rsp_cap = NULL;
                hreq = &s->hreq;
                hreq->req.cap = NULL;
+               hreq->rsp.cap = NULL;
                hreq->hdr_idx.v = NULL;
                hreq->hdr_idx.size = hreq->hdr_idx.used = 0;
 
@@ -226,7 +226,7 @@ int event_accept(int fd) {
 
 
                        if (p->fiprm->nb_rsp_cap > 0) {
-                               if ((s->rsp_cap =
+                               if ((hreq->rsp.cap =
                                     pool_alloc_from(p->fiprm->rsp_cap_pool, p->fiprm->nb_rsp_cap*sizeof(char *)))
                                    == NULL) { /* no memory */
                                        if (hreq->req.cap != NULL)
@@ -236,15 +236,15 @@ int event_accept(int fd) {
                                        pool_free(session, s);
                                        return 0;
                                }
-                               memset(s->rsp_cap, 0, p->fiprm->nb_rsp_cap*sizeof(char *));
+                               memset(hreq->rsp.cap, 0, p->fiprm->nb_rsp_cap*sizeof(char *));
                        }
 
 
                        if ((hreq->hdr_idx.v =
                             pool_alloc_from(p->hdr_idx_pool, hreq->hdr_idx.size*sizeof(*hreq->hdr_idx.v)))
                            == NULL) { /* no memory */
-                               if (s->rsp_cap != NULL)
-                                       pool_free_to(p->fiprm->rsp_cap_pool, s->rsp_cap);
+                               if (hreq->rsp.cap != NULL)
+                                       pool_free_to(p->fiprm->rsp_cap_pool, hreq->rsp.cap);
                                if (hreq->req.cap != NULL)
                                        pool_free_to(p->fiprm->req_cap_pool, hreq->req.cap);
                                close(cfd); /* nothing can be done for this fd without memory */
@@ -333,8 +333,8 @@ int event_accept(int fd) {
                if ((s->req = pool_alloc(buffer)) == NULL) { /* no memory */
                        if (hreq->hdr_idx.v != NULL)
                                pool_free_to(p->hdr_idx_pool, hreq->hdr_idx.v);
-                       if (s->rsp_cap != NULL)
-                               pool_free_to(p->fiprm->rsp_cap_pool, s->rsp_cap);
+                       if (hreq->rsp.cap != NULL)
+                               pool_free_to(p->fiprm->rsp_cap_pool, hreq->rsp.cap);
                        if (hreq->req.cap != NULL)
                                pool_free_to(p->fiprm->req_cap_pool, hreq->req.cap);
                        close(cfd); /* nothing can be done for this fd without memory */
@@ -356,8 +356,8 @@ int event_accept(int fd) {
                        pool_free(buffer, s->req);
                        if (hreq->hdr_idx.v != NULL)
                                pool_free_to(p->hdr_idx_pool, hreq->hdr_idx.v);
-                       if (s->rsp_cap != NULL)
-                               pool_free_to(p->fiprm->rsp_cap_pool, s->rsp_cap);
+                       if (hreq->rsp.cap != NULL)
+                               pool_free_to(p->fiprm->rsp_cap_pool, hreq->rsp.cap);
                        if (hreq->req.cap != NULL)
                                pool_free_to(p->fiprm->req_cap_pool, hreq->req.cap);
                        close(cfd); /* nothing can be done for this fd without memory */
index e25536fc00dbf65414ba1ed24102209c0355644f..80528162152a408d0812ce3271353ccf69a7d1a9 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -368,9 +368,9 @@ void sess_log(struct session *s)
                        for (hdr = 0; hdr < fe->nb_rsp_cap; hdr++) {
                                if (hdr)
                                        *(h++) = '|';
-                               if (s->rsp_cap[hdr] != NULL)
+                               if (hreq->rsp.cap[hdr] != NULL)
                                        h = encode_string(h, tmpline + sizeof(tmpline) - 4,
-                                                         '#', hdr_encode_map, s->rsp_cap[hdr]);
+                                                         '#', hdr_encode_map, hreq->rsp.cap[hdr]);
                        }
                        *(h++) = '}';
                }
index 92e818c028cb96d91a5bd1c597db2f308964dc32..83af0c7e418d55cb1d4d6653bd30c2da5dc2fa46 100644 (file)
@@ -2192,16 +2192,21 @@ int process_srv(struct session *t)
                                        if ((h->namelen + 2 <= ptr - rep->h) &&
                                            (rep->h[h->namelen] == ':') &&
                                            (strncasecmp(rep->h, h->name, h->namelen) == 0)) {
+                                               if (hreq->rsp.cap[h->index] == NULL)
+                                                       hreq->rsp.cap[h->index] =
+                                                               pool_alloc_from(h->pool, h->len + 1);
 
-                                               if (t->rsp_cap[h->index] == NULL)
-                                                       t->rsp_cap[h->index] = pool_alloc_from(h->pool, h->len + 1);
+                                               if (hreq->rsp.cap[h->index] == NULL) {
+                                                       Alert("HTTP capture : out of memory.\n");
+                                                       continue;
+                                               }
 
                                                len = ptr - (rep->h + h->namelen + 2);
                                                if (len > h->len)
                                                        len = h->len;
 
-                                               memcpy(t->rsp_cap[h->index], rep->h + h->namelen + 2, len);
-                                               t->rsp_cap[h->index][len]=0;
+                                               memcpy(hreq->rsp.cap[h->index], rep->h + h->namelen + 2, len);
+                                               hreq->rsp.cap[h->index][len]=0;
                                        }
                                }
                
index 3e1cc61614e2e8612659071d356b7a97d7afc8e8..1bf0f27df6106e6315d2fc98f20249633d7af729 100644 (file)
@@ -45,13 +45,13 @@ void session_free(struct session *s)
        if (hreq->hdr_idx.v != NULL)
                pool_free_to(s->fe->hdr_idx_pool, hreq->hdr_idx.v);
 
-       if (s->rsp_cap != NULL) {
+       if (hreq->rsp.cap != NULL) {
                struct cap_hdr *h;
                for (h = s->fe->fiprm->rsp_cap; h; h = h->next) {
-                       if (s->rsp_cap[h->index] != NULL)
-                               pool_free_to(h->pool, s->rsp_cap[h->index]);
+                       if (hreq->rsp.cap[h->index] != NULL)
+                               pool_free_to(h->pool, hreq->rsp.cap[h->index]);
                }
-               pool_free_to(s->fe->fiprm->rsp_cap_pool, s->rsp_cap);
+               pool_free_to(s->fe->fiprm->rsp_cap_pool, hreq->rsp.cap);
        }
        if (hreq->req.cap != NULL) {
                struct cap_hdr *h;