* when reading HTTP headers, the proxy needs some spare space to add or rewrite
* headers if needed. The size of this spare is defined with MAXREWRITE. So it
* is not possible to process headers longer than BUFSIZE-MAXREWRITE bytes. By
- * default, BUFSIZE=16384 bytes and MAXREWRITE=BUFSIZE/2, so the maximum length
- * of headers accepted is 8192 bytes, which is in line with Apache's limits.
+ * default, BUFSIZE=16384 bytes and MAXREWRITE=min(1024,BUFSIZE/2), so the
+ * maximum length of headers accepted is 15360 bytes.
*/
#ifndef BUFSIZE
#define BUFSIZE 16384
// reserved buffer space for header rewriting
#ifndef MAXREWRITE
-#define MAXREWRITE (BUFSIZE / 2)
+#define MAXREWRITE 1024
#endif
#ifndef REQURI_LEN
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
- if (global.tune.maxrewrite >= global.tune.bufsize / 2)
- global.tune.maxrewrite = global.tune.bufsize / 2;
chunk_init(&trash, realloc(trash.str, global.tune.bufsize), global.tune.bufsize);
alloc_trash_buffers(global.tune.bufsize);
}
goto out;
}
global.tune.maxrewrite = atol(args[1]);
- if (global.tune.maxrewrite >= global.tune.bufsize / 2)
- global.tune.maxrewrite = global.tune.bufsize / 2;
+ if (global.tune.maxrewrite < 0) {
+ Alert("parsing [%s:%d] : '%s' expects a positive integer argument.\n", file, linenum, args[0]);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+ }
}
else if (!strcmp(args[0], "tune.idletimer")) {
unsigned int idle;
},
.tune = {
.bufsize = BUFSIZE,
- .maxrewrite = MAXREWRITE,
+ .maxrewrite = -1,
.chksize = BUFSIZE,
.reserved_bufs = RESERVED_BUFS,
.pattern_cache = DEFAULT_PAT_LRU_SIZE,
if (global.tune.recv_enough == 0)
global.tune.recv_enough = MIN_RECV_AT_ONCE_ENOUGH;
+ if (global.tune.maxrewrite < 0)
+ global.tune.maxrewrite = MAXREWRITE;
+
if (global.tune.maxrewrite >= global.tune.bufsize / 2)
global.tune.maxrewrite = global.tune.bufsize / 2;