372 Commits

Author SHA1 Message Date
Tanmoy Sarkar
a0e4806962 refactor(companion): Cache configs for shutdown, drop dead setting
companion_manager_stop_timeout() re-read the config file mid-shutdown,
where a since-changed or removed file could raise. Cache the configs at
manager spawn and use them; fall back to a guarded build when no manager
has spawned yet.

Drop companion_manager_reload_timeout: the setting was defined but never
read anywhere. The reload path restarts the single manager via the main
loop and does not bound its wait on this value.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 23:30:48 +05:30
Tanmoy Sarkar
3f479157d7 feat(companion): Add companion process config settings 2026-06-09 15:17:43 +05:30
Ankush Menat
c20f3a3784 fix: Support configuring via envvar 2026-05-28 16:59:47 +05:30
Ankush Menat
c24711b795 fix: Increase default slow request threshold 2026-05-28 16:59:45 +05:30
Ankush Menat
7dc4d184be refactor: Simpler implementation
Just do multiple queues, nothing else.
2026-05-28 16:33:54 +05:30
Ankush Menat
ec6af68013 fix: Remove hardcoded paths for slow prediction 2026-05-28 16:01:02 +05:30
Ankush Menat
ee9bf1e950 feat: Adaptive queueing of slow/fast requests 2026-05-27 11:58:54 +05:30
Mond WAN
d05b6c5425 Fix typo in the getgrnam
getgrnam is under grp module instead of pwd
2025-03-14 18:01:52 +00:00
Benoit Chesneau
e75c3533e3
Merge pull request #3189 from pajod/patch-py36
chore: eat Python 2 leftovers
2024-08-10 10:40:40 +02:00
benoitc
9357b28dd8 keep document user in access_log_format setting 2024-08-10 10:19:36 +02:00
Benoit Chesneau
3f56d76548
Merge pull request #3192 from pajod/patch-allowed-script-name
22.0.0 regression: We need a better default treatment of SCRIPT_NAME
2024-08-09 09:05:57 +02:00
Paul J. Dorn
687b78d20c config defaults: PATH_NAME and ::1 for proxy
* PATH_NAME is used like SCRIPT_NAME: include both
* replicate changed forwarded-allow-ips default to proxy_allow_ips
2024-08-08 18:15:42 +02:00
Paul J. Dorn
3e042e8269 Configurable list of forwarder headers 2024-08-07 20:15:13 +02:00
Paul J. Dorn
01bcdb1d12 Exempt SCRIPT_NAME from newly introduced --header-map treatment 2024-08-07 20:10:47 +02:00
Paul J. Dorn
2bc931e7d9 whitespace handling in header field values
Strip whitespace also *after* header field value.
Simply refuse obsolete header folding (a default-off
option to revert is temporarily provided).
While we are at it, explicitly handle recently
introduced http error classes with intended status code.
2024-08-07 19:42:16 +02:00
Paul J. Dorn
6c3296e177 update docs
re-apply typo fix from 628a0bcb61ef3a211d67dfd68ad1ba161cccb3b8
reflect removal of setting from 555d2fa27f2d891f23bd03890e4a826b5018c6b4
2024-08-07 18:21:36 +02:00
Paul J. Dorn
6245e2c03b docs: unresolved reference (the reference is not named after the class name) 2024-08-07 18:16:20 +02:00
Benoit Chesneau
ad7c1de132
Merge pull request #3080 from odyfatouros/Fix-#3079-worker_class-parameter-accepts-class
Fix for issue #3079, worker_class parameter accepts a class
2024-08-07 08:47:20 +02:00
benoitc
555d2fa27f don't tolerate wrong te headers
changes:

- Just follow the new TE specification (https://datatracker.ietf.org/doc/html/rfc9112#name-transfer-encoding)
 here and accept to introduce a breaking change.
- gandle multiple TE on one line

** breaking changes ** : invalid  headers and position will now return
an error.
2024-08-06 23:47:01 +02:00
Paul J. Dorn
eda9d456d3 forbid lone CR/LF and NUL in headers
New parser rule: refuse HTTP requests where a header field value
contains characters that
a) should never appear there in the first place,
b) might have lead to incorrect treatment in a proxy in front, and
c) might lead to unintended behaviour in applications.

From RFC 9110 section 5.5:
"Field values containing CR, LF, or NUL characters are invalid and
dangerous, due to the varying ways that implementations might parse
and interpret those characters; a recipient of CR, LF, or NUL within
a field value MUST either reject the message or replace each of those
characters with SP before further processing or forwarding of that
message."
2024-07-31 01:28:30 +02:00
Paul J. Dorn
422b18acea class Name(object): -> class Name: 2024-04-22 03:33:30 +02:00
Paul J. Dorn
4323027b1e drop long-default - coding: utf-8 2024-04-22 03:33:14 +02:00
Eisuke Kawashima
628a0bcb61
chore: fix typos 2024-03-25 08:31:59 +09:00
Randall Leeds
660fd8d850 Fix references to non-existent 20.2 version in configuration settings
Close #3043.
2023-12-28 19:57:14 -08:00
Paul J. Dorn
7ebe442d08 strict HTTP version validation
Note: This is unrelated to a reverse proxy potentially talking HTTP/3 to clients.
This is about the HTTP protocol version spoken to Gunicorn, which is HTTP/1.0 or HTTP/1.1.

Little legitimate need for processing HTTP 1 requests with ambiguous version numbers.
Broadly refuse.

Co-authored-by: Ben Kallus <benjamin.p.kallus.gr@dartmouth.edu>
2023-12-15 13:33:31 +01:00
Paul J. Dorn
ac29c9b0a7 fail-safe on unsupported request framing
If we promise wsgi.input_terminated, we better get it right - or not at all.
* chunked encoding on HTTP <= 1.1
* chunked not last transfer coding
* multiple chinked codings
* any unknown codings (yes, this too! because we do not detect unusual syntax that is still chunked)
* empty coding (plausibly harmless, but not see in real life anyway - refused, for the moment)
2023-12-15 13:33:31 +01:00
Paul J. Dorn
72b8970dbf silently drop or refuse header names w/ underscore
Ambiguous mappings open a bottomless pit of "what is user input and what is proxy input" confusion.
Default to what everyone else has been doing for years now, silently drop.

see also https://nginx.org/r/underscores_in_headers
2023-12-15 13:33:31 +01:00
Paul J. Dorn
b2846783d7 strict: header field validation: stop casefolding
* refusing lowercase and ASCII 0x23 (#) had been partially enforced before
* do not casefold by default, HTTP methods are case sensitive
2023-12-15 13:33:31 +01:00
Odysseas Fatouros
ca2ce2c76b Fix for issue #3079, worker_class parameter accepts a class 2023-10-13 16:15:40 +02:00
unknown
48d670f087 update pylint version, and fix linter issues 2023-05-17 18:45:59 +03:00
Tero Saarni
d8c3b1490e Deprecate ssl_version option
This change defaults SSLContext to Python's ssl.create_default_context() and
marks ssl_version option as deprecated. The option value will be ignored and
warnign will be printed in stderr.

The ssl_version option was depending on old method of setting TLS min/max
version, which has not worked well anymore with modern Python versions.
2023-05-11 17:45:57 +03:00
Benoit Chesneau
f859de498a
Merge pull request #2634 from YingjieQiao/docs/cert_reqs
docs: add examples for cert-reqs
2023-05-11 10:09:44 +02:00
Benoit Chesneau
f955a0c18c
Merge pull request #2649 from Nordix/sslcontext
Update SSLContext handling
2023-05-11 09:51:37 +02:00
Florian Demmer
0b5c4aea99
Fix LogRecord pre-formatting, closes #2801 2023-05-07 22:46:10 +02:00
Benoit Chesneau
4a1c402e2c
Merge pull request #2384 from larribas/2066-statsd-socket
Allow reporting StatsD metrics over UDS sockets
2023-05-07 20:39:11 +02:00
Benoit Chesneau
db9de0175d
Merge branch 'master' into 1775-support-log-config-json 2023-05-07 16:16:56 +02:00
Klaas van Schelven
d04ddfd117 Docs: add link to configuration file
See #2136 (not a full solution, but at least one more path
to understanding added)
2023-02-08 12:04:53 +01:00
samypr100
2ea4699fe7
Fixing errors reported by pycodestyle 2023-01-22 21:20:11 -05:00
Tero Saarni
ac8bc3a455 Regenerated rst docs
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
2022-03-15 19:05:30 +02:00
Tero Saarni
362a52bd84 Added parameter to ssl_context hook for constructing default context
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
2022-02-11 19:26:56 +02:00
Tero Saarni
5a581c0b14 Update SSLContext handling
* Change deprecated ssl.wrap_socket() to SSLContext.wrap_context().
* Add new server hook to allow user to create custom SSLContext.
* Updated the documentation.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
2021-09-12 17:39:06 +03:00
yingjie
0215f5dc36 docs: add examples for cert-reqs 2021-08-26 22:41:12 +08:00
Michael Milton
b83448bfb4
Clarify the secure scheme behaviour, with examples (#2492) 2021-03-08 10:58:22 -08:00
Smiler Lee
fb05e33377 Fix a naming error for gthread worker 2021-02-24 17:43:17 +08:00
Adam Johnson
6fd97b9559 Document that WEB_CONCURRENCY is set by, at least, Heroku 2021-01-06 03:14:31 +02:00
Adam Johnson
dad99a1bd4 Update gunicorn_ext.py 2021-01-06 03:14:31 +02:00
Randall Leeds
37994e1422 Remove the --log-config-dict flag
There is no support for decoding any dictionary supplied on the command
line. The only way to supply a dictionary logging config is through the
configuration file.

Close #1909.
2020-12-18 20:49:11 -05:00
Gastón Avila
b80a329354
Correction on default value for config file (#2408)
Running gunicorn project.app while having a file called gunicorn.conf.py
in the current directory will read configuration from that file and actually fail
if the file raises an exception.
2020-08-22 20:13:02 +03:00
larribas
2a16fcd3ce Test and defend against the specific case where the statsd hostname is 'unix' 2020-07-20 10:16:42 +02:00
larribas
15abac7e81 Allow specifying a UDS socket address through --statsd-host 2020-07-19 20:11:09 +02:00