45 Commits

Author SHA1 Message Date
Jorge Niedbalski R
a716285ed0 Added coverage for get_default_config_file, also a test for default config overrides 2013-06-22 07:14:08 -07:00
benoitc
5e08c27495 improve STDOUT/STDERR logging redirection.
Instead of faking STDIN/STDERR to a fake object that we close on reopen,
simply redirect them to a file and reopen this one when need.

Should fix most of the issues on #309
2013-04-21 11:31:58 +02:00
jean-philippe serafin
87474ffce1 add test_atom_defaults() 2013-04-18 15:58:55 +02:00
benoitc
ac1af72922 s/optparse/argparse 2012-12-25 06:19:06 +01:00
Qiangning Hong
174c34ec9c add nworkers_changed hook
This hook will be called whenever the number of workers is set.
2012-12-21 15:43:26 +01:00
Konstantin Enchant
aac56c9d55 Added response arg for post_request hook. 2012-12-16 10:21:01 +01:00
benoitc
b7b51adf13 allows gunicorn to bind to multiple address
Allows gunicorn to listen on different interface. It can be either ipv6,
unix or ipv4 sockets.

Ex:

    gunicorn -w3 -b 127.0.0.1:8001 -b 127.0.0.1:8000 -b [::1]:8000 test:app

fix #444
2012-12-14 10:18:39 +01:00
Eric Shull
e58f8b59b7 Add isatty method to LazyWriter. 2012-11-16 07:59:55 +01:00
benoitc
bb00d41ff9 fixes for py27 2012-10-24 23:08:15 +02:00
benoitc
8d453fb341 all tests pass under python 3 2012-10-24 22:07:35 +02:00
Konstantin Enchant
8f4edfa0bf Callable hooks for paster config. 2012-09-27 19:14:41 +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
d28366a683 Add ForwardedAllowIPS option. 2012-08-26 22:28:34 +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
Djoume Salvetti
9e308e317f Improves performance of http.body.Body.readline() 2012-05-10 11:24:54 +02:00
benoitc
be19f414ae close #294 .
Thanks for the patch
2012-02-20 11:23:58 +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
9631c2ab5a with_statement. spotted by @jbergstroem on irc 2010-07-05 17:06:17 +02:00
benoitc
c89ce5f5ad debug behavior has changed. 2010-07-01 07:20:36 +02:00
Randall Leeds
4e20f606f1 fix inconsistencies with urlparse lib 2010-07-01 13:15:15 +08:00
Paul J. Davis
2763fe8e9f Added tests for invalid requests.
Need to flesh out more error cases.
2010-06-03 16:11:18 -04:00
Paul J. Davis
5af1273fc2 Added more valid request tests.
Found and fixed a couple read and readline related bugs.
2010-06-03 16:11:18 -04:00
Paul J. Davis
27cc404f1f Imported simplehttp request tests. 2010-06-03 16:11:17 -04:00
benoitc
dd620a5788 add missing license header 2010-05-22 11:59:41 +02:00
Paul J. Davis
6ffbe54734 Added unit tests for new Config code. 2010-05-21 22:54:22 -04:00
benoitc
c785be0780 new parser using StringIO, faster than concatenate strings. Lot of fixes
in TeeInput.
2010-03-06 20:47:39 +01:00
jbergstroem
e5e6b70895 Fix failed tests due to lack of passing config to a Request 2010-03-03 15:44:54 +08:00
benoitc
ea02c5e073 this seems to fix problem with upload. Tested with the django app 2010-02-28 22:46:35 +01:00
benoitc
d92364af71 new read_partial function. We also now use buffer in parser. 2010-02-28 22:46:35 +01:00
benoitc
c557ecc93b the way to get full path is "SCHEME://SERVER_NAME:SERVER_PORT" +
SCRIPT_NAME + PATH_INFO
2010-02-18 11:31:24 +01:00
Benoit Chesneau
87336be46b remove unused import/var and some fixes 2010-02-16 14:24:40 +01:00
Paul J. Davis
47776417d5 Repeated headers request test.
Test the environ produced by a request object for repeated headers.
2010-02-10 11:01:14 -05:00
Paul J. Davis
588b48b2cd Comma separate repeated request headers.
RFC 2616 says that only headers that are allowed to have comma separated
values are acceptable for repetition. Though it doesn't specify an error
condition for that situation. I reckon the cleanest way would be to list
the headers that are acceptable for repetition, and return a 400 Bad
Request.
2010-02-10 10:55:09 -05:00
Paul J. Davis
9e717b8f9c Refactoring the worker loop.
Accidentally got a bit carried away.
2010-01-31 17:45:26 -05:00
Eric Florenzano
036735b456 Used PyFlakes to detect and fix unneeded imports. 2010-01-21 13:23:35 -08:00
Benoit Chesneau
2f959f9251 typo 2010-01-21 01:20:09 +01:00
Benoit Chesneau
ec644bdf90 rename http_parser.py to parser.py we are already in http module 2010-01-21 01:13:12 +01:00
Benoit Chesneau
6da023a7da clean a litle the rep 2010-01-21 00:51:48 +01:00
Benoit Chesneau
b568852465 add request unitests. fix TeeInput & parser 2010-01-21 00:18:42 +01:00
Benoit Chesneau
ba6db08825 add license headers to tests 2010-01-20 22:01:45 +01:00
Benoit Chesneau
db01c210a2 Set blocking to 0 back since we prevented inheritence of the socket the socket. 2010-01-20 18:06:35 +01:00
Benoit Chesneau
bfeb4f9416 fix chunked encoding and add tests 2010-01-20 16:21:20 +01:00
Benoit Chesneau
d4ae13cde0 forgot to commit tests 2010-01-20 15:21:57 +01:00