mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
parent
2b839ca144
commit
70cfb0d818
@ -793,8 +793,12 @@ class LimitRequestFieldSize(Setting):
|
||||
desc = """\
|
||||
Limit the allowed size of an HTTP request header field.
|
||||
|
||||
Value is a number from 0 (unlimited) to 8190. to set the limit
|
||||
on the allowed size of an HTTP request header field.
|
||||
Value is a positive number or 0. Setting it to 0 will allow unlimited
|
||||
header field sizes.
|
||||
|
||||
.. warning::
|
||||
Setting this parameter to a very high or unlimited value can open
|
||||
up for DDOS attacks.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ from gunicorn._compat import urlsplit
|
||||
|
||||
MAX_REQUEST_LINE = 8190
|
||||
MAX_HEADERS = 32768
|
||||
MAX_HEADERFIELD_SIZE = 8190
|
||||
DEFAULT_MAX_HEADERFIELD_SIZE = 8190
|
||||
|
||||
HEADER_RE = re.compile("[\x00-\x1F\x7F()<>@,;:\[\]={} \t\\\\\"]")
|
||||
METH_RE = re.compile(r"[A-Z0-9$-_.]{3,20}")
|
||||
@ -41,12 +41,11 @@ class Message(object):
|
||||
or self.limit_request_fields > MAX_HEADERS):
|
||||
self.limit_request_fields = MAX_HEADERS
|
||||
self.limit_request_field_size = cfg.limit_request_field_size
|
||||
if (self.limit_request_field_size < 0
|
||||
or self.limit_request_field_size > MAX_HEADERFIELD_SIZE):
|
||||
self.limit_request_field_size = MAX_HEADERFIELD_SIZE
|
||||
if self.limit_request_field_size < 0:
|
||||
self.limit_request_field_size = DEFAULT_MAX_HEADERFIELD_SIZE
|
||||
|
||||
# set max header buffer size
|
||||
max_header_field_size = self.limit_request_field_size or MAX_HEADERFIELD_SIZE
|
||||
max_header_field_size = self.limit_request_field_size or DEFAULT_MAX_HEADERFIELD_SIZE
|
||||
self.max_buffer_headers = self.limit_request_fields * \
|
||||
(max_header_field_size + 2) + 4
|
||||
|
||||
|
||||
3
tests/requests/invalid/017.http
Normal file
3
tests/requests/invalid/017.http
Normal file
File diff suppressed because one or more lines are too long
5
tests/requests/invalid/017.py
Normal file
5
tests/requests/invalid/017.py
Normal file
@ -0,0 +1,5 @@
|
||||
from gunicorn.config import Config
|
||||
from gunicorn.http.errors import LimitRequestHeaders
|
||||
|
||||
cfg = Config()
|
||||
request = LimitRequestHeaders
|
||||
@ -1,5 +1,4 @@
|
||||
from gunicorn.config import Config
|
||||
from gunicorn.http.errors import LimitRequestHeaders
|
||||
|
||||
cfg = Config()
|
||||
cfg.set('limit_request_line', 0)
|
||||
|
||||
3
tests/requests/valid/026.http
Normal file
3
tests/requests/valid/026.http
Normal file
File diff suppressed because one or more lines are too long
14
tests/requests/valid/026.py
Normal file
14
tests/requests/valid/026.py
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user