mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
[MINOR] move the response headers to the http_req
This commit is contained in:
parent
ee68cf29bb
commit
362b34d05c
@ -139,7 +139,7 @@ struct http_msg {
|
|||||||
int sor; /* Start Of Request, relative to buffer */
|
int sor; /* Start Of Request, relative to buffer */
|
||||||
int col, sov; /* current header: colon, start of value */
|
int col, sov; /* current header: colon, start of value */
|
||||||
int eoh; /* End Of Headers, relative to buffer */
|
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 */
|
union { /* useful start line pointers, relative to buffer */
|
||||||
struct {
|
struct {
|
||||||
int l; /* request line length (not including CR) */
|
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 sockaddr_in srv_addr; /* the address to connect to */
|
||||||
struct server *srv; /* the server being used */
|
struct server *srv; /* the server being used */
|
||||||
struct pendconn *pend_pos; /* if not NULL, points to the position in the pending queue */
|
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 http_req hreq; /* current HTTP request being processed. Should become a list. */
|
||||||
struct {
|
struct {
|
||||||
int logwait; /* log fields waiting to be collected : LW_* */
|
int logwait; /* log fields waiting to be collected : LW_* */
|
||||||
|
18
src/client.c
18
src/client.c
@ -198,9 +198,9 @@ int event_accept(int fd) {
|
|||||||
s->uniq_id = totalconn;
|
s->uniq_id = totalconn;
|
||||||
p->cum_feconn++; /* cum_beconn will be increased once assigned */
|
p->cum_feconn++; /* cum_beconn will be increased once assigned */
|
||||||
|
|
||||||
s->rsp_cap = NULL;
|
|
||||||
hreq = &s->hreq;
|
hreq = &s->hreq;
|
||||||
hreq->req.cap = NULL;
|
hreq->req.cap = NULL;
|
||||||
|
hreq->rsp.cap = NULL;
|
||||||
hreq->hdr_idx.v = NULL;
|
hreq->hdr_idx.v = NULL;
|
||||||
hreq->hdr_idx.size = hreq->hdr_idx.used = 0;
|
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 (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 *)))
|
pool_alloc_from(p->fiprm->rsp_cap_pool, p->fiprm->nb_rsp_cap*sizeof(char *)))
|
||||||
== NULL) { /* no memory */
|
== NULL) { /* no memory */
|
||||||
if (hreq->req.cap != NULL)
|
if (hreq->req.cap != NULL)
|
||||||
@ -236,15 +236,15 @@ int event_accept(int fd) {
|
|||||||
pool_free(session, s);
|
pool_free(session, s);
|
||||||
return 0;
|
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 =
|
if ((hreq->hdr_idx.v =
|
||||||
pool_alloc_from(p->hdr_idx_pool, hreq->hdr_idx.size*sizeof(*hreq->hdr_idx.v)))
|
pool_alloc_from(p->hdr_idx_pool, hreq->hdr_idx.size*sizeof(*hreq->hdr_idx.v)))
|
||||||
== NULL) { /* no memory */
|
== NULL) { /* no memory */
|
||||||
if (s->rsp_cap != NULL)
|
if (hreq->rsp.cap != NULL)
|
||||||
pool_free_to(p->fiprm->rsp_cap_pool, s->rsp_cap);
|
pool_free_to(p->fiprm->rsp_cap_pool, hreq->rsp.cap);
|
||||||
if (hreq->req.cap != NULL)
|
if (hreq->req.cap != NULL)
|
||||||
pool_free_to(p->fiprm->req_cap_pool, hreq->req.cap);
|
pool_free_to(p->fiprm->req_cap_pool, hreq->req.cap);
|
||||||
close(cfd); /* nothing can be done for this fd without memory */
|
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 ((s->req = pool_alloc(buffer)) == NULL) { /* no memory */
|
||||||
if (hreq->hdr_idx.v != NULL)
|
if (hreq->hdr_idx.v != NULL)
|
||||||
pool_free_to(p->hdr_idx_pool, hreq->hdr_idx.v);
|
pool_free_to(p->hdr_idx_pool, hreq->hdr_idx.v);
|
||||||
if (s->rsp_cap != NULL)
|
if (hreq->rsp.cap != NULL)
|
||||||
pool_free_to(p->fiprm->rsp_cap_pool, s->rsp_cap);
|
pool_free_to(p->fiprm->rsp_cap_pool, hreq->rsp.cap);
|
||||||
if (hreq->req.cap != NULL)
|
if (hreq->req.cap != NULL)
|
||||||
pool_free_to(p->fiprm->req_cap_pool, hreq->req.cap);
|
pool_free_to(p->fiprm->req_cap_pool, hreq->req.cap);
|
||||||
close(cfd); /* nothing can be done for this fd without memory */
|
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);
|
pool_free(buffer, s->req);
|
||||||
if (hreq->hdr_idx.v != NULL)
|
if (hreq->hdr_idx.v != NULL)
|
||||||
pool_free_to(p->hdr_idx_pool, hreq->hdr_idx.v);
|
pool_free_to(p->hdr_idx_pool, hreq->hdr_idx.v);
|
||||||
if (s->rsp_cap != NULL)
|
if (hreq->rsp.cap != NULL)
|
||||||
pool_free_to(p->fiprm->rsp_cap_pool, s->rsp_cap);
|
pool_free_to(p->fiprm->rsp_cap_pool, hreq->rsp.cap);
|
||||||
if (hreq->req.cap != NULL)
|
if (hreq->req.cap != NULL)
|
||||||
pool_free_to(p->fiprm->req_cap_pool, hreq->req.cap);
|
pool_free_to(p->fiprm->req_cap_pool, hreq->req.cap);
|
||||||
close(cfd); /* nothing can be done for this fd without memory */
|
close(cfd); /* nothing can be done for this fd without memory */
|
||||||
|
@ -368,9 +368,9 @@ void sess_log(struct session *s)
|
|||||||
for (hdr = 0; hdr < fe->nb_rsp_cap; hdr++) {
|
for (hdr = 0; hdr < fe->nb_rsp_cap; hdr++) {
|
||||||
if (hdr)
|
if (hdr)
|
||||||
*(h++) = '|';
|
*(h++) = '|';
|
||||||
if (s->rsp_cap[hdr] != NULL)
|
if (hreq->rsp.cap[hdr] != NULL)
|
||||||
h = encode_string(h, tmpline + sizeof(tmpline) - 4,
|
h = encode_string(h, tmpline + sizeof(tmpline) - 4,
|
||||||
'#', hdr_encode_map, s->rsp_cap[hdr]);
|
'#', hdr_encode_map, hreq->rsp.cap[hdr]);
|
||||||
}
|
}
|
||||||
*(h++) = '}';
|
*(h++) = '}';
|
||||||
}
|
}
|
||||||
|
@ -2192,16 +2192,21 @@ int process_srv(struct session *t)
|
|||||||
if ((h->namelen + 2 <= ptr - rep->h) &&
|
if ((h->namelen + 2 <= ptr - rep->h) &&
|
||||||
(rep->h[h->namelen] == ':') &&
|
(rep->h[h->namelen] == ':') &&
|
||||||
(strncasecmp(rep->h, h->name, h->namelen) == 0)) {
|
(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)
|
if (hreq->rsp.cap[h->index] == NULL) {
|
||||||
t->rsp_cap[h->index] = pool_alloc_from(h->pool, h->len + 1);
|
Alert("HTTP capture : out of memory.\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
len = ptr - (rep->h + h->namelen + 2);
|
len = ptr - (rep->h + h->namelen + 2);
|
||||||
if (len > h->len)
|
if (len > h->len)
|
||||||
len = h->len;
|
len = h->len;
|
||||||
|
|
||||||
memcpy(t->rsp_cap[h->index], rep->h + h->namelen + 2, len);
|
memcpy(hreq->rsp.cap[h->index], rep->h + h->namelen + 2, len);
|
||||||
t->rsp_cap[h->index][len]=0;
|
hreq->rsp.cap[h->index][len]=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,13 +45,13 @@ void session_free(struct session *s)
|
|||||||
if (hreq->hdr_idx.v != NULL)
|
if (hreq->hdr_idx.v != NULL)
|
||||||
pool_free_to(s->fe->hdr_idx_pool, hreq->hdr_idx.v);
|
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;
|
struct cap_hdr *h;
|
||||||
for (h = s->fe->fiprm->rsp_cap; h; h = h->next) {
|
for (h = s->fe->fiprm->rsp_cap; h; h = h->next) {
|
||||||
if (s->rsp_cap[h->index] != NULL)
|
if (hreq->rsp.cap[h->index] != NULL)
|
||||||
pool_free_to(h->pool, s->rsp_cap[h->index]);
|
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) {
|
if (hreq->req.cap != NULL) {
|
||||||
struct cap_hdr *h;
|
struct cap_hdr *h;
|
||||||
|
Loading…
Reference in New Issue
Block a user