Commit Graph

2269 Commits

Author SHA1 Message Date
L. Kärkkäinen
1aac4f546b Merge branch 'master' into streaming 2020-03-26 08:59:33 +02:00
L. Kärkkäinen
120f0262f7
Fix Ctrl+C and tests on Windows. (#1808)
* Fix Ctrl+C on Windows.

* Disable testing of a function N/A on Windows.

* Add test for coverage, avoid crash on missing _stopping.

* Initialise StreamingHTTPResponse.protocol = None

* Improved comments.

* Reduce amount of data in test_request_stream to avoid failures on Windows.

* The Windows test doesn't work on Windows :(

* Use port numbers more likely to be free than 8000.

* Disable the other signal tests on Windows as well.

* Windows doesn't properly support SO_REUSEADDR, so that's disabled in Python, and thus rebinding fails. For successful testing, reuse port instead.

* app.run argument handling: added server kwargs (alike create_server), added warning on extra kwargs, made auto_reload explicit argument. Another go at Windows tests

* Revert "app.run argument handling: added server kwargs (alike create_server), added warning on extra kwargs, made auto_reload explicit argument. Another go at Windows tests"

This reverts commit dc5d682448.

* Use random test server port on most tests. Should avoid port/addr reuse issues.

* Another test to random port instead of 8000.

* Fix deprecation warnings about missing name on Sanic() in tests.

* Linter and typing

* Increase test coverage

* Rewrite test for ctrlc_windows_workaround

* py36 compat

* py36 compat

* py36 compat

* Don't rely on loop internals but add a stopping flag to app.

* App may be restarted.

* py36 compat

* Linter

* Add a constant for OS checking.

Co-authored-by: L. Kärkkäinen <tronic@users.noreply.github.com>
2020-03-25 21:42:46 -07:00
L. Kärkkäinen
f928ad22be These must be tuples + hack mypy warnings away. 2020-03-25 15:32:41 +02:00
L. Kärkkäinen
6bedec97ae Linter and typing 2020-03-25 15:05:51 +02:00
L. Kärkkäinen
5832764aab Merge branch 'master' into streaming 2020-03-25 14:58:45 +02:00
L. Kärkkäinen
42af6e1af6 Add a check for request body functions and a test for NotImplementedError. 2020-03-25 14:35:09 +02:00
L. Kärkkäinen
4db075ffc1
Streaming migration for 20.3 release (#1800)
* Compatibility and deprecations for Sanic 20.3 in preparation of the streaming branch.

* Add test for new API.

* isort tests

* More coverage

* json takes str, not bytes

Co-authored-by: L. Kärkkäinen <tronic@users.noreply.github.com>
2020-03-24 10:11:09 -07:00
L. Kärkkäinen
f1c85eb1f8 Add clarifying comment 2020-03-22 18:07:35 +02:00
L. Kärkkäinen
23e54fc546 Fix tracking of HTTP stage when writing to transport fails. 2020-03-20 17:20:20 +02:00
Kevin Guillaumond
60b4efad67
Update config docs to match DEFAULT_CONFIG (#1803)
* Set REAL_IP_HEADER's default value to "X-Real-IP"

* Update config instead
2020-03-14 08:57:39 -07:00
L. Kärkkäinen
9098493da9 Linter 2020-03-10 17:03:11 +02:00
L. Kärkkäinen
17d100400f Middleware and error handling refactoring. 2020-03-10 16:45:26 +02:00
L. Kärkkäinen
d2d6008eec Need to check if transport is closing to avoid getting stuck in sending loops after peer has disconnected. 2020-03-10 15:23:22 +02:00
L. Kärkkäinen
2adcc72e06 Response middleware ran by async request.respond(). 2020-03-09 16:59:36 +02:00
L. Kärkkäinen
2b63d2bed4 Import ordering 2020-03-09 16:15:08 +02:00
L. Kärkkäinen
9dc2ec966c Linting 2020-03-09 15:44:06 +02:00
L. Kärkkäinen
a9d984e2f8 Cleanup processed_headers some more. 2020-03-09 15:28:02 +02:00
L. Kärkkäinen
32ee5399d9 Duplicate set-cookie headers were being produced. 2020-03-09 15:09:31 +02:00
L. Kärkkäinen
a0e61ae5c6 35 % speedup in HTTP/1.1 response formatting (not so much overall effect). 2020-03-09 14:35:06 +02:00
L. Kärkkäinen
c86c29e239 Avoid special handling of StreamingHTTPResponse. 2020-03-08 17:46:31 +02:00
L. Kärkkäinen
5351cda979 Unify response header processing of ASGI and asyncio modes. 2020-03-08 17:34:08 +02:00
L. Kärkkäinen
d348bb4ff4 Refactoring and cleanup. 2020-03-08 16:56:22 +02:00
L. Kärkkäinen
990ac52a1a Header values should be strictly ASCII but both UTF-8 and Latin-1 exist. Use UTF-8B to
cope with all.
2020-03-08 14:33:28 +02:00
L. Kärkkäinen
cbfeb1c99c Fix chunked mode crash. 2020-03-08 12:23:22 +02:00
L. Kärkkäinen
4c34508695 Merge branch 'master' into streaming 2020-03-06 16:30:58 +02:00
L. Kärkkäinen
319388d78b
Remove the old request context API deprecated in 19.9. Use request.ctx instead. (#1801)
Co-authored-by: L. Kärkkäinen <tronic@users.noreply.github.com>
2020-03-05 21:40:46 -08:00
L. Kärkkäinen
730de6afda Default to no maximum request size for streaming handlers. 2020-03-04 15:25:50 +02:00
L. Kärkkäinen
eb66621544 json takes str, not bytes 2020-03-04 13:21:49 +02:00
L. Kärkkäinen
dc6b4925df Add test for new API. 2020-03-04 12:25:46 +02:00
L. Kärkkäinen
cbabe7ec4a Avoid error messages on PayloadTooLarge. 2020-03-02 17:06:18 +02:00
L. Kärkkäinen
c2e5674a73 Add a missing check in case of close_if_idle on a dead connection. 2020-03-02 16:55:48 +02:00
L. Kärkkäinen
9c21457b58 Always try to consume request body, plus minor cleanup. 2020-03-02 16:34:21 +02:00
L. Kärkkäinen
85d58d7b2b Messages further tuned. 2020-03-02 15:36:43 +02:00
L. Kärkkäinen
96a8b5c3a0 Init http.response = None 2020-03-02 15:33:23 +02:00
L. Kärkkäinen
e73f26b0a3 More specific error messages on Payload Too Large. 2020-03-02 15:32:12 +02:00
L. Kärkkäinen
50cca39185 Stricter handling of request header size 2020-03-02 15:07:40 +02:00
L. Kärkkäinen
9baa2419cd Merge branch 'master' into streaming 2020-03-02 14:05:15 +02:00
Subham Roy
ce71514d71
bump httpx dependency version to 0.11.1 (#1794) 2020-03-01 11:42:11 -08:00
L. Kärkkäinen
7833d70d9e
Allow multiple workers on MacOS with Python 3.8. Fallback to single worker on Windows until pickling can be fixed. (#1798) 2020-03-01 11:41:09 -08:00
L. Kärkkäinen
7e93ee102c Typing 2020-03-01 18:21:09 +02:00
L. Kärkkäinen
08353637fd Linter 'n fixes 2020-03-01 17:40:01 +02:00
L. Kärkkäinen
31a8706b42 Fix a middleware cancellation handling test with py38. 2020-03-01 17:10:04 +02:00
L. Kärkkäinen
d918655bbb Py 3.8 check for deprecated loop argument. 2020-03-01 16:57:03 +02:00
L. Kärkkäinen
0712026e14 Remove unused code. 2020-03-01 16:36:42 +02:00
L. Kärkkäinen
1c42a5ef4e Minor fixes. 2020-03-01 16:34:58 +02:00
L. Kärkkäinen
5a96996003 A test was missing that body_init/body_push/body_finish are never called. Rewritten using receive_body and case switching to make it fail if bypassed. 2020-03-01 16:34:20 +02:00
L. Kärkkäinen
c0a0b50bc1 Remove unnecessary variables, optimise performance. 2020-03-01 15:38:18 +02:00
L. Kärkkäinen
fc16594138 Disable custom protocol test 2020-03-01 14:53:04 +02:00
L. Kärkkäinen
5086076590 Linter 2020-03-01 13:21:02 +02:00
L. Kärkkäinen
f8298939c0 Merge branch 'master' into streaming 2020-03-01 13:13:39 +02:00