MEDIUM: tune.http.maxhdr makes it possible to configure the maximum number of HTTP headers
For a long time, the max number of headers was taken as a part of the buffer
size. Since the header size can be configured at runtime, it does not make
much sense anymore.
Nothing was making it necessary to have a static value, so let's turn this into
a tunable with a default value of 101 which equals what was previously used.
diff --git a/include/common/defaults.h b/include/common/defaults.h
index 0a4f420..8647131 100644
--- a/include/common/defaults.h
+++ b/include/common/defaults.h
@@ -58,9 +58,9 @@
#define MAX_MATCH 10
// max # of headers in one HTTP request or response
-// By default, about 100 headers per 8 kB.
+// By default, about 100 headers (+1 for the first line)
#ifndef MAX_HTTP_HDR
-#define MAX_HTTP_HDR ((BUFSIZE+79)/80)
+#define MAX_HTTP_HDR 101
#endif
// max # of headers in history when looking for header #-X
diff --git a/include/types/global.h b/include/types/global.h
index 078a1d5..56110e8 100644
--- a/include/types/global.h
+++ b/include/types/global.h
@@ -97,6 +97,7 @@
int server_rcvbuf; /* set server rcvbuf to this value if not null */
int chksize; /* check buffer size in bytes, defaults to BUFSIZE */
int pipesize; /* pipe size in bytes, system defaults if zero */
+ int max_http_hdr; /* max number of HTTP headers, use MAX_HTTP_HDR if zero */
} tune;
struct {
char *prefix; /* path prefix of unix bind socket */
diff --git a/include/types/proto_http.h b/include/types/proto_http.h
index d9bf830..f1b3eef 100644
--- a/include/types/proto_http.h
+++ b/include/types/proto_http.h
@@ -322,7 +322,7 @@
*/
struct http_txn {
struct http_msg req; /* HTTP request message */
- struct hdr_idx hdr_idx; /* array of header indexes (max: MAX_HTTP_HDR) */
+ struct hdr_idx hdr_idx; /* array of header indexes (max: global.tune.max_http_hdr) */
unsigned int flags; /* transaction flags */
http_meth_t meth; /* HTTP method */