[MINOR] move the response headers to the http_req
diff --git a/include/types/session.h b/include/types/session.h
index 1edc2f8..bbb0ebe 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -139,7 +139,7 @@
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 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_* */
diff --git a/src/client.c b/src/client.c
index 8bcd143..e4babba 100644
--- a/src/client.c
+++ b/src/client.c
@@ -198,9 +198,9 @@
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 @@
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 @@
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 @@
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 @@
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 */
diff --git a/src/log.c b/src/log.c
index e25536f..8052816 100644
--- a/src/log.c
+++ b/src/log.c
@@ -368,9 +368,9 @@
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++) = '}';
}
diff --git a/src/proto_http.c b/src/proto_http.c
index 92e818c..83af0c7 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -2192,16 +2192,21 @@
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;
}
}
diff --git a/src/session.c b/src/session.c
index 3e1cc61..1bf0f27 100644
--- a/src/session.c
+++ b/src/session.c
@@ -45,13 +45,13 @@
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;