38 Commits

Author SHA1 Message Date
Collin Anderson
f2ba62bc10 six 1.8.0 and gunicorn._compat
closes #904 and #905
2014-10-02 17:00:03 -04:00
Benoit Chesneau
26a796f200 Merge pull request #670 from gnotaras/bugfix-request-line-check
Fixed the request line length check.
2014-01-01 07:48:44 -08:00
George Notaras
b9fe01ca2c Fixed the request line length check. 2013-12-19 03:18:18 +02:00
Neil Williams
9d9e547316 proxy_allow_ips: Allow proxy protocol if "*" specified.
This makes proxy_allow_ips symmetrical with forwarded_allow_ips and is
useful in the same situations.
2013-12-17 13:48:27 -08:00
Alex Gaynor
b5c1810722 Only compiled some regexes used in HTTP parsing once
Currently they are parsed and compiled once per-HTTP request, which is
unnescary computation and makes stuff slower than it could be.
2013-08-28 20:23:53 -07:00
Adnane Belmadiaf
20cd49595a PEP8 fixes 2012-12-24 09:53:03 +01:00
benoitc
8d453fb341 all tests pass under python 3 2012-10-24 22:07:35 +02:00
benoitc
003c474fe2 handle bytes & native strings
This patch makes sure that we now handle correctly bytes and native
strings on python 3:

- In python 3, sockets are now taking and returning bytes.
- according to PEP3333, headers should be native strings and body in
  bytes.
2012-10-24 13:51:35 +02:00
benoitc
53ce50bc7b obvious syntax fixes preparing python3 support 2012-10-24 12:11:15 +02:00
Konstantin Kapustin
70534acde8 Implantation proxy protocol 2012-09-27 19:14:40 +02:00
Konstantin Kapustin
4be3282440 Check Content-Length header.
For not chunked request do validation Content-Length header and return 400 if invalid.
2012-09-27 19:14:40 +02:00
Konstantin Kapustin
4fdfc3a76b Fix LimitRequestLine check. 2012-08-20 16:02:52 +04:00
benoitc
4b478e1a66 fix request line check. close #390
We never had the possibility to check the limit since we were quitting
the loop before it.
2012-08-03 06:27:26 +02:00
Paul J. Davis
489e935038 Fix request line length check
We were accidentally including partial data when we didn't find the
request line terminating '\r\n'. This changes the check to make sure
we're testing the length after we assert there's no termination.
2012-07-04 15:53:10 -05:00
benoitc
ffecd64669 don't finish the loop if the headers length is too big 2012-05-25 12:27:40 +02:00
benoitc
d79ff999ce fix multiple issues with request limit
patch from Djoume Salvetti . address the following issues in gunicorn:

* Gunicorn does not limit the size of a request header (the
* limit_request_field_size configuration parameter is not used)

* When the configured request limit is lower than its maximum value, the
* maximum value is used instead. For instance if limit_request_line is
* set to 1024, gunicorn will only limit the request line to 4096 chars
* (this issue also affects limit_request_fields)

* Request limits are not limited to their maximum authorized values. For
* instance it is possible to set limit_request_line to 64K (this issue
* also affects limit_request_fields)

* Setting limit_request_fields and limit_request_field_size to 0 does
* not make them unlimited. The following patch allows limit_request_line
* and limit_request_field_size to be unlimited. limit_request_fields can
* no longer be unlimited (I can't imagine 32K fields to not be enough
* but I have a use case where 8K for the request line is not enough).

* Parsing errors (premature client disconnection) are not reported

* When request line limit is exceeded the configured value is reported
* instead of the effective value.
2012-05-24 12:13:34 +02:00
benoitc
86ea0c6f8d remove this buggy & useless check 2012-02-25 15:14:11 +01:00
benoitc
7a1c58f236 test number of headers fields and size.
Add --limit-request-fields (limit_request_fields) and
--limit-request-field-size (limit-request-field-size) options.

- limit_request_fields:

    Value is a number from 0 (unlimited) to 32768. This parameter is
    used to limit the number of headers in a request to prevent DDOS
    attack. Used with the `limit_request_field_size` it allows more
    safety.

- limit_request_field_size:

    Value is a number from 0 (unlimited) to 8190. to set the limit
    on the allowed size of an HTTP request header field.
2012-02-20 10:36:13 +01:00
benoitc
b7b0979ad9 check if Request Line is too large.
You can now pass the parameter --limit-request-line or set the
limit_request_line in your configuration file to set the max size of the
request line in bytes.

This parameter is used to limit the allowed size of a client's HTTP
request-line. Since the request-line consists of the HTTP method, URI,
and protocol version, this directive places a restriction on the length
of a request-URI allowed for a request on the server. A server needs
this value to be large enough to hold any of its resource names,
including any information that might be passed in the query part of a
GET request. By default this value is 4094 and can't be larger than
8190.

This parameter can be used to prevent any DDOS attack.
2012-02-20 09:56:06 +01:00
benoitc
6766c14793 pass config to the http parser. 2012-02-20 07:02:55 +01:00
benoitc
613378529b close #297 .
When the path starts with //, urlsplit considers it as a relative uri
while the RDF says it shouldnt (
http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2).

While I'm remove unncessary tests on netloc. The path never contains a
netloc or port.
2012-02-20 06:06:07 +01:00
benoitc
f168a21dae fix whitespaces 2012-02-19 11:27:46 +01:00
Randall Leeds
55de904e9d add access logging for gevent_* workers 2011-09-18 03:50:13 -07:00
Anand Chitipothu
5aabdc0ae2 Preserve semicolons in the path. #215
`urlparse.urlparse` splits the url at semicolons and calls it params. Since
the WSGI doesn't have any special treatment for params, they should be
preserved and passed to the wsgi app. Using `urlparse.urlsplit` to
avoid splitting the params.
2011-08-21 07:41:44 +02:00
benoitc
c8d3b7764f don't truncate, just create a new instance. 2010-12-27 14:07:08 +01:00
benoitc
7715199b48 it's better to test when you use the right code to do it. We had a
blocking operation django example (we read a file already on the fs and
recreate another which blocked async schedulers).

While I'm here ease the code of eventlet worker. Just use the convenient
eventlet.serve function which already manage what we do and revert sopme
useless changes in body and header parsing.
2010-09-02 14:55:56 +02:00
benoitc
d7d6fa382b rever for now optimisations done when collecting headers. It doens't
give good results
2010-08-12 06:48:05 +02:00
benoitc
cf8a31264e use splitlines function 2010-08-11 22:36:17 +02:00
benoitc
2b0f37b6b1 again no need to iter headers. Get the values we need the first time 2010-08-11 19:18:25 +02:00
benoitc
08fe410fb3 no need to iter headers to find connection header since we could have it
the first time we get the list
2010-08-11 19:10:48 +02:00
benoitc
42d97c3815 more optimisations. no need to uppercase or lowercase each time we want
to test an header since the parser already send the headers in uppercase
2010-08-11 11:12:10 +02:00
benoitc
d1858d2284 optimize a little bit headers parsing 2010-08-11 09:24:16 +02:00
Randall Leeds
4e20f606f1 fix inconsistencies with urlparse lib 2010-07-01 13:15:15 +08:00
benoitc
a461817309 fix websocket with protocol 076. Fix from tom on irc. Thanks! 2010-06-24 16:20:48 +02:00
benoitc
2f06305ce4 fix wsgi env. 2010-06-22 14:05:11 +02:00
benoitc
d5f2b5358a Refactored the configuration system.
Some preliminary work on refactoring the configuration system to
allow for some backwards compatibility with Python 2.4.
2010-06-17 19:45:51 -04:00
benoitc
516adafcbe fix some errors & add headers. unitests still broken 2010-06-03 16:11:17 -04:00
Paul J. Davis
0d32ab1356 Initial steps for importing simplehttp. 2010-06-03 16:11:16 -04:00