src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \
src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
- src/session.o
+ src/session.o src/hdr_idx.o
haproxy: $(OBJS)
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \
src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
- src/session.o
+ src/session.o src/hdr_idx.o
all: haproxy
// max # of matches per regexp
#define MAX_MATCH 10
+// max # of headers in one HTTP request or response
+// By default, about 100 headers per 8 kB.
+#ifndef MAX_HTTP_HDR
+#define MAX_HTTP_HDR ((BUFSIZE+79)/80)
+#endif
+
// cookie delimitor in "prefix" mode. This character is inserted between the
// persistence cookie and the original value. The '~' is allowed by RFC2965,
// and should not be too common in server names.
struct cap_hdr *req_cap; /* chained list of request headers to be captured */
struct cap_hdr *rsp_cap; /* chained list of response headers to be captured */
void *req_cap_pool, *rsp_cap_pool; /* pools of pre-allocated char ** used to build the sessions */
+ void *hdr_idx_pool; /* pools of pre-allocated int* used for headers indexing */
char *req_add[MAX_NEWHDR], *rsp_add[MAX_NEWHDR]; /* headers to be added */
int grace; /* grace time after stop request */
char *check_req; /* HTTP or SSL request to use for PR_O_HTTP_CHK|PR_O_SSL3_CHK */
#include <types/queue.h>
#include <types/server.h>
#include <types/task.h>
+#include <types/hdr_idx.h>
/* various session flags, bits values 0x01 to 0x20 (shift 0) */
struct pendconn *pend_pos; /* if not NULL, points to the position in the pending queue */
char **req_cap; /* array of captured request headers (may be NULL) */
char **rsp_cap; /* array of captured response headers (may be NULL) */
+ struct hdr_idx hdr_idx; /* array of header indexes (max: MAX_HTTP_HDR) */
struct chunk req_line; /* points to first line */
struct chunk auth_hdr; /* points to 'Authorization:' header */
struct {
#include <proto/client.h>
#include <proto/fd.h>
#include <proto/log.h>
+#include <proto/hdr_idx.h>
#include <proto/proto_http.h>
#include <proto/stream_sock.h>
#include <proto/task.h>
t->context = s;
s->task = t;
-#ifdef BUILD_WITH_PROXY
- s->proxy = p;
-#endif
s->be = s->fe = s->fi = p;
s->cli_state = (p->mode == PR_MODE_HTTP) ? CL_STHEADERS : CL_STDATA; /* no HTTP headers for non-HTTP proxies */
else
s->rsp_cap = NULL;
+ if (p->mode == PR_MODE_HTTP) {
+ s->hdr_idx.size = MAX_HTTP_HDR;
+ if ((s->hdr_idx.v =
+ pool_alloc_from(p->hdr_idx_pool, s->hdr_idx.size*sizeof(*s->hdr_idx.v)))
+ == NULL) { /* no memory */
+ if (s->rsp_cap != NULL)
+ pool_free_to(p->rsp_cap_pool, s->rsp_cap);
+ if (s->req_cap != NULL)
+ pool_free_to(p->req_cap_pool, s->req_cap);
+ close(cfd); /* nothing can be done for this fd without memory */
+ pool_free(task, t);
+ pool_free(session, s);
+ return 0;
+ }
+ hdr_idx_init(&s->hdr_idx);
+ }
+ else {
+ s->hdr_idx.size = s->hdr_idx.used = 0;
+ s->hdr_idx.v = NULL;
+ }
+
if ((p->mode == PR_MODE_TCP || p->mode == PR_MODE_HTTP)
&& (p->logfac1 >= 0 || p->logfac2 >= 0)) {
struct sockaddr_storage sockname;
}
if ((s->req = pool_alloc(buffer)) == NULL) { /* no memory */
+ if (s->hdr_idx.v != NULL)
+ pool_free_to(p->hdr_idx_pool, s->hdr_idx.v);
if (s->rsp_cap != NULL)
pool_free_to(p->rsp_cap_pool, s->rsp_cap);
if (s->req_cap != NULL)