]> git.ipfire.org Git - thirdparty/starlette.git/log
thirdparty/starlette.git
4 years agoAdd starsessions library to the 3rd-party list. (#1225)
Alex Oleshkevich [Wed, 22 Sep 2021 08:35:17 +0000 (11:35 +0300)] 
Add starsessions library to the 3rd-party list. (#1225)

* Add starsessions library to the 3rd-party list.

* Update docs/third-party-packages.md

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agoAdd `routes=routes` to schemas documentation (#1241)
Ju [Sat, 18 Sep 2021 13:35:28 +0000 (01:35 +1200)] 
Add `routes=routes` to schemas documentation (#1241)

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agoPropose a roll your own framework solution (#1137)
jpic ∞ [Sat, 18 Sep 2021 13:21:04 +0000 (15:21 +0200)] 
Propose a roll your own framework solution (#1137)

* Propose a roll your own framework solution

* Update docs/third-party-packages.md

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agoAlign __getitem__ type with scope type (#1118)
Sam Burba [Sat, 18 Sep 2021 13:16:05 +0000 (06:16 -0700)] 
Align __getitem__ type with scope type (#1118)

Scope does not only contain strings, see full spec here:
https://asgi.readthedocs.io/en/latest/specs/www.html#websocket-connection-scope

Fixes #1117

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agoFix typos in config.md code examples (#1065)
eprikazc [Sat, 18 Sep 2021 13:10:00 +0000 (16:10 +0300)] 
Fix typos in config.md code examples (#1065)

* Fix typos in config.md code examples

* Update docs/config.md

* Update docs/config.md

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agodatasette-auth-github is now asgi-auth-github (#967)
Simon Willison [Sat, 18 Sep 2021 12:39:39 +0000 (05:39 -0700)] 
datasette-auth-github is now asgi-auth-github (#967)

https://github.com/simonw/datasette-auth-github/issues/63

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Co-authored-by: Erik <eraker@gmail.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agotest_database_execute_many: remove unnecessary statement (#778)
Daniel Hahler [Sat, 18 Sep 2021 12:10:40 +0000 (14:10 +0200)] 
test_database_execute_many: remove unnecessary statement (#778)

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agoAdd dark theme for the documentation (#1230)
Piotr Gnus [Sat, 18 Sep 2021 11:08:29 +0000 (13:08 +0200)] 
Add dark theme for the documentation (#1230)

* mkdocs: expanded theme configuration to add alternative dark theme.
  The default theme will be determined by the users system theme by the
  `prefers-color-scheme` media query.

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agoadd typing overloads for Config.__call__ (#1097)
Steve Dignam [Sat, 18 Sep 2021 10:44:11 +0000 (06:44 -0400)] 
add typing overloads for Config.__call__ (#1097)

* add typing overloads for Config.__call__

This allows for more precise return types instead of the current `Any`.

We have 3 overload cases here:

1. handles cases where the user provides an explicit `cast` argument.

   ```
   reveal_type(config("POOL_SIZE", cast=int))
   # note: Revealed type is 'int'

   reveal_type(config("DEBUG", cast=bool, default=None))
   # note: Revealed type is 'Union[bool, None]'
   ```

2. handles no cast or default being passed

   ```
   reveal_type(config("FOO"))
   # note: Revealed type is 'str'
   ```

3. handles no cast being provided, and the default not being `str`

   ```
   reveal_type(config("DB_NAME", default=None))
   # note: Revealed type is 'Union[str, None]'

   reveal_type(config("FOO", default=False))
   # note: Revealed type is 'Union[str, bool]'
   ```

* ignore overloads from code coverage

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agoUpdate responses.md (#1069)
Pax [Sat, 18 Sep 2021 10:38:52 +0000 (03:38 -0700)] 
Update responses.md (#1069)

- Fix typo ("Third party middleware" to "...responses")
- Fix w3 link (current link leads to 404; I followed links from archive.org to get the "latest" spec)
- Format it similarly to "Third party middleware" (use h4, use the class name as header)

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agoAdd missing await on database section on docs (#1226)
Amin Alaee [Thu, 16 Sep 2021 17:49:59 +0000 (22:19 +0430)] 
Add missing await on database section on docs (#1226)

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agoAdd BaseHTTPMiddleware import on docs (#1285)
Lukas Kahwe Smith [Thu, 16 Sep 2021 12:48:32 +0000 (14:48 +0200)] 
Add BaseHTTPMiddleware import on docs (#1285)

4 years agoAdd starlette-cramjam link to the docs (#1283)
Vincent Sarago [Thu, 16 Sep 2021 12:22:05 +0000 (14:22 +0200)] 
Add starlette-cramjam link to the docs (#1283)

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years agoIgnore loop deprecation warnings originating inside asyncio (#1287)
Marcelo Trylesinski [Thu, 16 Sep 2021 12:16:25 +0000 (14:16 +0200)] 
Ignore loop deprecation warnings originating inside asyncio (#1287)

4 years agoInclude FastAPI link
Tom Christie [Thu, 19 Aug 2021 14:40:50 +0000 (15:40 +0100)] 
Include FastAPI link

4 years agoAdd FastAPI sponsorship (#1271)
Tom Christie [Thu, 19 Aug 2021 14:17:41 +0000 (15:17 +0100)] 
Add FastAPI sponsorship (#1271)

4 years agoFix BadSignature exception handling in SessionMiddleware (#1264)
Hannes Küttner [Sat, 14 Aug 2021 14:38:50 +0000 (16:38 +0200)] 
Fix BadSignature exception handling in SessionMiddleware (#1264)

4 years agoprepare release 0.16.0 (#1233) 0.16.0
Thomas Grainger [Mon, 19 Jul 2021 07:08:36 +0000 (08:08 +0100)] 
prepare release 0.16.0 (#1233)

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Jamie Hewland <jhewland@gmail.com>
4 years agoignore charset_normalizer related warning (#1242)
Thomas Grainger [Fri, 16 Jul 2021 10:07:55 +0000 (11:07 +0100)] 
ignore charset_normalizer related warning (#1242)

4 years agoDocument the lifespan event handler parameter (#1110)
Emil Melnikov [Thu, 15 Jul 2021 16:13:43 +0000 (18:13 +0200)] 
Document the lifespan event handler parameter (#1110)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
4 years agouse an async context manager factory for lifespan (#1227)
Thomas Grainger [Sat, 3 Jul 2021 17:43:24 +0000 (18:43 +0100)] 
use an async context manager factory for lifespan (#1227)

4 years ago ensure TestClient requests run in the same EventLoop as lifespan (#1213)
Thomas Grainger [Sat, 3 Jul 2021 16:39:25 +0000 (17:39 +0100)] 
 ensure TestClient requests run in the same EventLoop as lifespan  (#1213)

* ensure TestClient requests run in the same EventLoop as lifespan

* for lifespan task verification, use native task identity rather than anyio.abc.TaskInfo equality

https://github.com/agronholm/anyio/issues/324

* remove redundant pragma: no cover

* it's now a loop_id not a threading.ident

* replace Protocol with plain Callable TypeAlias

* use lifespan_context to actually open a task group

trio should complain if used incorrectly here.

* assign self.portal once, schedule reset immediately after assignment

* inline apps into their tests

* make task/loop trackers nonlocals

4 years agoTestClient accepts backend and backend_options as arguments to constructor (#1211)
Thomas Grainger [Mon, 28 Jun 2021 20:36:13 +0000 (21:36 +0100)] 
TestClient accepts backend and backend_options as arguments to constructor (#1211)

as opposed to ClassVar assignment

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
Co-authored-by: Jordan Speicher <jordan@jspeicher.com>
Co-authored-by: Jordan Speicher <uSpike@users.noreply.github.com>
4 years agoreset the `__eq__` and `__hash__` of HTTPConnection to allow WebSockets to be added...
Thomas Grainger [Mon, 28 Jun 2021 12:02:18 +0000 (13:02 +0100)] 
reset the `__eq__` and `__hash__` of HTTPConnection to allow WebSockets to be added to … (#1039)

4 years ago:wrench: Add funding option (#1219)
Marcelo Trylesinski [Mon, 28 Jun 2021 10:15:08 +0000 (12:15 +0200)] 
:wrench: Add funding option (#1219)

4 years agoMake Jinja2Templates.get_env private & rename (#1218)
Amin Alaee [Sun, 27 Jun 2021 12:26:14 +0000 (16:56 +0430)] 
Make Jinja2Templates.get_env private & rename (#1218)

* make-jinja2-get-env-internal

* rename _get_env to _create_env

4 years agomkdocs: Set site_url (#1215)
Jamie Hewland [Fri, 25 Jun 2021 07:46:38 +0000 (08:46 +0100)] 
mkdocs: Set site_url (#1215)

4 years agoPrepare version 0.15.0 (#1202) 0.15.0
Jamie Hewland [Wed, 23 Jun 2021 08:31:02 +0000 (09:31 +0100)] 
Prepare version 0.15.0 (#1202)

* Prepare version 0.15.0

* Remember to add a note about websocket_connect

* Add date and blurb to release notes

* Bump version to 0.15.0

* Add note about fixing #1012

4 years agoFixed TestClient error when response headers missing (#1200)
Aber [Mon, 21 Jun 2021 08:09:19 +0000 (16:09 +0800)] 
Fixed TestClient error when response headers missing (#1200)

* Fixed https://github.com/abersheeran/asgi-ratelimit/issues/14

* lint it

* Black it

Co-authored-by: euri10 <euri10@users.noreply.github.com>
4 years agoTest on Python 3.10 (#1201)
Jamie Hewland [Sat, 19 Jun 2021 17:02:53 +0000 (18:02 +0100)] 
Test on Python 3.10 (#1201)

4 years agoUse coverage directly instead of pytest-cov (#1204)
Jamie Hewland [Sat, 19 Jun 2021 11:42:56 +0000 (12:42 +0100)] 
Use coverage directly instead of pytest-cov (#1204)

* Use coverage directly instead of pytest-cov

* Use coverage's source_pkgs

4 years agoClean up last bit of aiofiles after #1157 (#1203)
Jamie Hewland [Fri, 18 Jun 2021 15:40:09 +0000 (16:40 +0100)] 
Clean up last bit of aiofiles after #1157 (#1203)

4 years agoanyio integration (#1157)
Jordan Speicher [Fri, 18 Jun 2021 14:48:43 +0000 (09:48 -0500)] 
anyio integration (#1157)

* First whack at anyio integration

* Fix formatting

* Remove debug messages

* mypy fixes

* Update README.md

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
* Fix install_requires typo

* move_on_after blocks if deadline is too small

* Linter fixes

* Improve WSGI structured concurrency

* Tests use anyio

* Checkin progress on testclient

* Prep for anyio 3

* Remove debug backend option

* Use anyio 3.0.0rc1

* Remove old style executor from GraphQLApp

* Fix extra import

* Don't cancel task scope early

* Wait for wsgi sender to finish before exiting

* Use memory object streams in websocket tests

* Test on asyncio, asyncio+uvloop, and trio

* Formatting fixes

* run_until_first_complete doesn't need a return

* Fix middleware app call

* Simplify middleware exceptions

* Use anyio for websocket test

* Set STARLETTE_TESTCLIENT_ASYNC_BACKEND in tests

* Pass async backend to portal

* Formatting fixes

* Bump anyio

* Cleanup portals and add TestClient.async_backend

* Use anyio.run_async_from_thread to send from worker thread

* Use websocket_connect as context manager

* Document changes in TestClient

* Formatting fix

* Fix websocket raises coverage

* Update to anyio 3.0.0rc3 and replace aiofiles

* Apply suggestions from code review

Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
* Bump to require anyio 3.0.0 final

* Remove mention of aiofiles in README.md

* Pin jinja2 to releases before 3 due to DeprecationWarnings

* Add task_group as application attribute

* Remove run_until_first_complete

* Undo jinja pin

* Refactor anyio.sleep into an event

* Use one less task in test_websocket_concurrency_pattern

* Apply review suggestions

* Rename argument

* fix start_task_soon type

* fix BaseHTTPMiddleware when used without Starlette

* Testclient receive() is a non-trapping function if the response is already complete

This allows for a zero deadline when waiting for a disconnect message

* Use variable annotation for async_backend

* Update docs regarding dependency on anyio

* Use CancelScope instead of move_on_after in request.is_disconnected

* Cancel task group after returning middleware response

Add test for https://github.com/encode/starlette/issues/1022

* Add link to anyio backend options in testclient docs

* Add types-dataclasses

* Re-implement starlette.concurrency.run_until_first_complete and add a test

* Fix type on handler callable

* Apply review comments to clarify run_until_first_complete scope

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
4 years agoDeduplicate failure text in CORS preflight response (#1199)
laggardkernel [Sun, 13 Jun 2021 15:59:17 +0000 (23:59 +0800)] 
Deduplicate failure text in CORS preflight response (#1199)

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
4 years agoCleanup param "workers" in WSGIMiddleware (#1146)
laggardkernel [Sun, 13 Jun 2021 15:54:34 +0000 (23:54 +0800)] 
Cleanup param "workers" in WSGIMiddleware (#1146)

Param "workers" in WSGIMiddleware.__init__ has not been used
since 0.6.3, which is changed in GH-164, commit 96c51c.

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
4 years agoAdd compresslevel to GZipMiddleware (#1128)
Nikolay Bulatov [Fri, 11 Jun 2021 09:55:32 +0000 (12:55 +0300)] 
Add compresslevel to GZipMiddleware (#1128)

* Add compresslevel to GZipMiddleware
Current default level = 9
New default level = 1

Documentation gzip: https://docs.python.org/3/library/gzip.html
Benchmarks: https://tukaani.org/lzma/benchmarks.html

Reformate code

Default compress level in gzip now = 9

* Add compresslevel to GZipMiddleware

Default level = 9

Documentation gzip: https://docs.python.org/3/library/gzip.html
Benchmarks: https://tukaani.org/lzma/benchmarks.html

Reformate code

Default compress level in gzip now = 9

Co-authored-by: Tom Christie <tom@tomchristie.com>
4 years agoSmall Pythonic code changes for datastructures.py file (#1167)
Shahriyar Rzayev [Fri, 11 Jun 2021 08:46:39 +0000 (12:46 +0400)] 
Small Pythonic code changes for datastructures.py file (#1167)

* Small Pythonic code changes for datastructures.py file

* Reverting back .gitignore changes

* reverting back newline in .gitignore

* Reverting back the changes as requested during merge review

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
4 years ago🐛 Fix type hint issues due to mypy upgrade to 0.902 (#1197)
Marcelo Trylesinski [Fri, 11 Jun 2021 08:39:57 +0000 (10:39 +0200)] 
🐛 Fix type hint issues due to mypy upgrade to 0.902 (#1197)

4 years agoUpdates to python 3.6+ syntax (#1189)
Jordan Speicher [Thu, 27 May 2021 18:54:43 +0000 (13:54 -0500)] 
Updates to python 3.6+ syntax (#1189)

* Convert comment type hints to annotations

* Update to python 3.6+ syntax

* Explicitly state response type annotation

* Explicitly define queue generic type

4 years agoFix readme for ChannelBox package (#1188)
Andrey Sobolev [Wed, 26 May 2021 08:15:39 +0000 (11:15 +0300)] 
Fix readme for ChannelBox package (#1188)

Fix domain name

4 years agoUpdate README.md (#1185)
Tom Christie [Tue, 25 May 2021 10:35:18 +0000 (11:35 +0100)] 
Update README.md (#1185)

Drop defunct "community" link, since we're just using GitHub "discussions" now.

4 years agoUse non-deprecated jinja2.pass_context in Jinja 3.0+ (#1183)
Jamie Hewland [Thu, 13 May 2021 14:11:14 +0000 (15:11 +0100)] 
Use non-deprecated jinja2.pass_context in Jinja 3.0+ (#1183)

4 years agoAdd better exception msg for duplicated param names (#1177)
Yurii Karabas [Tue, 4 May 2021 09:36:16 +0000 (12:36 +0300)] 
Add better exception msg for duplicated param names (#1177)

4 years agoUpdate authentication.md (#1165)
hitrust [Wed, 28 Apr 2021 09:42:02 +0000 (17:42 +0800)] 
Update authentication.md (#1165)

import 'Starlette'

Co-authored-by: Joe <nigelchiang@outlook.com>
4 years agoRemoved the empty elif clause as it has no effect (#1168)
Shahriyar Rzayev [Wed, 28 Apr 2021 09:35:01 +0000 (13:35 +0400)] 
Removed the empty elif clause as it has no effect (#1168)

Co-authored-by: Joe <nigelchiang@outlook.com>
4 years agoRemoved redundant parantheses as returning with comma will return tuple (#1171)
Shahriyar Rzayev [Wed, 28 Apr 2021 09:28:54 +0000 (13:28 +0400)] 
Removed redundant parantheses as returning with comma will return tuple (#1171)

Co-authored-by: Joe <nigelchiang@outlook.com>
4 years agoReplaced mutable default argument with None to eliminate anti-pattern (#1173)
Shahriyar Rzayev [Wed, 28 Apr 2021 09:24:42 +0000 (13:24 +0400)] 
Replaced mutable default argument with None to eliminate anti-pattern (#1173)

Co-authored-by: Joe <nigelchiang@outlook.com>
4 years agoReplaced built-in type name with type_ as it may shadow the global scope; removed...
Shahriyar Rzayev [Wed, 28 Apr 2021 09:20:14 +0000 (13:20 +0400)] 
Replaced built-in type name with type_ as it may shadow the global scope; removed redundant variable assignment (#1174)

4 years agoprevent setup from generating an incorrect top_level.txt file in the wheel distributi...
wim glenn [Wed, 21 Apr 2021 08:29:35 +0000 (03:29 -0500)] 
prevent setup from generating an incorrect top_level.txt file in the wheel distribution (#1166)

4 years agouse quote instead of quote_plus for RedirectResponse location header (#1164)
Ben Falk [Wed, 14 Apr 2021 19:14:53 +0000 (15:14 -0400)] 
use quote instead of quote_plus for RedirectResponse location header (#1164)

* use quote instead of quote_plus for RedirectResponse location header

adjust safe characters: rem. duplicate & symbol

add test for redirect quoting

* remove unused import

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
4 years agoSet explicit Origin in CORS preflight response if allow_credentials is True and allow...
Josh Wilson [Wed, 14 Apr 2021 19:10:20 +0000 (12:10 -0700)] 
Set explicit Origin in CORS preflight response if allow_credentials is True and allow_origins is wildcard (#1113)

* Set explicit Origin in CORS preflight response if allow_credentials is True and allow_origins is wildcard

When making a preflight request, the browser makes no indication as to whether the actual subsequent
request will pass up credentials. However, unless the preflight response explicitly allows the
request's `Origin` in the `Access-Control-Response-Header`, the browser will fail the CORS check and
prevent the actual follow-up CORS request. This means that responding with the `*` wildcard is not
sufficient to allow preflighted credentialed requests. The current workaround is to provide an
equivalently permissive `allow_origin_regex` pattern.

The `simple_response()` code already performs similar logic which currently only applies to
non-preflighted requests since the browser would never make a preflighted request that hits this
code due to this issue:

```
if self.allow_all_origins and has_cookie:
    headers["Access-Control-Allow-Origin"] = origin
```

This just bring the two halves inline with each other.

* Add Vary header to preflight response if allow_credentials

* Use allow_explicit_origin() for preflight request_headers

This simplifies the code slightly by using this recently added method.

It has some trade-offs, though. We now construct a `MutableHeaders` instead of a simple `dict` when
copying the pre-computed preflight headers, and we move the `Vary` header construction out of the
pre-computation and into the call handler.

I think it makes the code more maintainable and the added per-call computation is minimal.

* Convert MutableHeaders to dict for PlainTextResponse

* Revert back to dict() for preflight headers

This also names and caches some of the boolean tests in __init__() which we use in later if-blocks.
This follows the existing pattern in order to better self-document the code.

* Clean up comments

* Remove unused self.allow_credentials attribute

4 years agoAdd HEAD to CORS ALL_METHODS list (#1112)
Josh Wilson [Tue, 6 Apr 2021 20:38:48 +0000 (13:38 -0700)] 
Add HEAD to CORS ALL_METHODS list (#1112)

* Add HEAD to CORS ALL_METHODS list

The HEAD method is conspicuously absent from the allowed methods list when `allow_methods="*"` is
used. This doesn't really affect CORS preflight requests, as HEAD requests aren't preflighted by the
browser, but it does prevent the actual cross-origin HEAD response from being read by the calling
app.
[This can catch people off-guard.](https://discuss.encode.io/t/for-cors-middleware-why-is-head-not-included-in-all-methods/939)

This simply adds HEAD to the `ALL_METHODS` list in the CORS middleware module and includes some
additional tests to validate the new behavior.

* Update tests/middleware/test_cors.py to use more explicit status code check

Co-authored-by: euri10 <euri10@users.noreply.github.com>
Co-authored-by: euri10 <euri10@users.noreply.github.com>
Co-authored-by: Jamie Hewland <jhewland@gmail.com>
4 years agoAdd Origin to Vary header on credentialed CORS response (#1111)
Josh Wilson [Tue, 6 Apr 2021 20:36:41 +0000 (13:36 -0700)] 
Add Origin to Vary header on credentialed CORS response (#1111)

* Add Origin to Vary header on credentialed CORS response

According to the [MDN CORS docs]
(https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Access-Control-Allow-Origin), the `Origin`
item should be added to the `Vary` header when the `Access-Control-Allow-Origin` is set to an
explicit origin value, as opposed to the `*` wildcard.

>If the server specifies a single origin (that may dynamically change based on the requesting origin
as part of a white-list) rather than the "*" wildcard, then the server should also include Origin in
the Vary response header — to indicate to clients that server responses will differ based on the
value of the Origin request header.

The existing code fails to update the `Vary` list when the server is configured to allow all
origins (`*`) and the request has a `Cookie` header (ie. credentialed). In that situation, the
`Access-Control-Allow-Origin` header will be set to the request's `Origin` value.

It appears this may have just been a simple oversight in the original implementation. This updates
the code to add `Origin` to the `Vary` header under these circumstancesIf it was intentionally
omitted, I'd be delighted to learn why.

* Add type annotations

* Add test to ensure that the vary header does not contain origin if request is non-credentialed

4 years agoDon't use 'raise exc from None' because it suppresses exception causes (#1158)
oTree-org [Mon, 29 Mar 2021 15:02:22 +0000 (23:02 +0800)] 
Don't use 'raise exc from None' because it suppresses exception causes (#1158)

Co-authored-by: oTree-org <chris@otree.org>
4 years agoMake session cookie use ASGI root path (#1147)
Mahmoud Hossam [Fri, 12 Mar 2021 12:49:52 +0000 (13:49 +0100)] 
Make session cookie use ASGI root path (#1147)

* Make session cookie use ASGI root path

* Check if ASGI root_path exists before using it

Co-authored-by: Tom Christie <tom@tomchristie.com>
* Remove comment

* Add test

Co-authored-by: Mahmoud Hanafy <mahmoud.hanafy@retresco.de>
Co-authored-by: Tom Christie <tom@tomchristie.com>
4 years agoFix docs syntax highlighting (#1136)
Jamie Hewland [Sun, 7 Feb 2021 19:06:30 +0000 (19:06 +0000)] 
Fix docs syntax highlighting (#1136)

* mkdocs: Use python-markdown-extensions syntax highlighter

* mkdocs: Use 2-space indent consistently in config file

4 years agoStaticFiles: Fix cache validation bug for deleted files in html mode (#1023)
ilunev [Fri, 5 Feb 2021 20:15:25 +0000 (23:15 +0300)] 
StaticFiles: Fix cache validation bug for deleted files in html mode (#1023)

* StaticFiles: Fix cache validation bug for deleted files in html mode

Previously StaticFiles would return 304 for a deleted file if its
Last-Modified date was the same as that of 404.html

* Use black formatter

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
4 years agoDeprecate built-in GraphQL support (#1135)
Jamie Hewland [Fri, 5 Feb 2021 19:13:39 +0000 (19:13 +0000)] 
Deprecate built-in GraphQL support (#1135)

* Deprecate GraphQLApp

* Add deprecation warning to pytest ignore list

* Tweak deprecation warnings

4 years agoVersion 0.14.2 (#1133) 0.14.2
Jamie Hewland [Tue, 2 Feb 2021 20:10:02 +0000 (20:10 +0000)] 
Version 0.14.2 (#1133)

* Prepare version 0.14.2

* Tweak changelog: Changed -> Fixed

4 years agoFix spelling (#1115)
John Bampton [Tue, 2 Feb 2021 11:13:59 +0000 (21:13 +1000)] 
Fix spelling (#1115)

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
4 years agodocs: fix simple typo, ougoging -> outgoing (#1120)
Tim Gates [Tue, 2 Feb 2021 11:09:29 +0000 (22:09 +1100)] 
docs: fix simple typo, ougoging -> outgoing (#1120)

There is a small typo in starlette/middleware/gzip.py.

Should read `outgoing` rather than `ougoging`.

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
4 years agoRemove self from websocker example app (#1103)
Denis Eliseev [Tue, 2 Feb 2021 11:01:03 +0000 (16:01 +0500)] 
Remove self from websocker example app (#1103)

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
4 years agoFix functools.partial async handlers for classmethods (#1106)
Vlad Stefan Munteanu [Tue, 2 Feb 2021 10:30:30 +0000 (12:30 +0200)] 
Fix functools.partial async handlers for classmethods (#1106)

* Showcase the bug

* Fixed functools.partial usage with classmethods

* Updated comment

* Updated docstring according to suggestion

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
Co-authored-by: Jamie Hewland <jhewland@gmail.com>
4 years agoFix middleware traceback fetching on Python 3.8+, fix ResourceWarnings in TestClient...
Jamie Hewland [Sun, 31 Jan 2021 11:43:07 +0000 (11:43 +0000)] 
Fix middleware traceback fetching on Python 3.8+, fix ResourceWarnings in TestClient, fix CI build (#1132)

* Add __init__ file for tests.middleware so Mypy 0.800 is happy

* testclient: Tie loop lifetime to thread

* ServerErrorMiddleware: Don't use undocumented TracebackException.exc_traceback attribute

4 years agoAdd missing status codes (#1096)
Roman [Mon, 23 Nov 2020 16:06:26 +0000 (19:06 +0300)] 
Add missing status codes (#1096)

4 years agoAdd 208 Already Reported status code (#1095)
Roman [Fri, 20 Nov 2020 09:18:39 +0000 (12:18 +0300)] 
Add 208 Already Reported status code (#1095)

4 years agoVersion 0.14.1 (#1088) 0.14.1
Jamie Hewland [Mon, 9 Nov 2020 15:15:31 +0000 (17:15 +0200)] 
Version 0.14.1 (#1088)

* Prepare version 0.14.1

* Add link to docs about custom JSON serialization

* Bump release date

* Add link to PR removing UJSONResponse

4 years agoRemove UJSONResponse (#1047)
Jamie Hewland [Sun, 8 Nov 2020 20:49:12 +0000 (22:49 +0200)] 
Remove UJSONResponse (#1047)

* Remove UJSONResponse

* Add documentation about custom JSON serialization

4 years agoVersion 0.14.0 (#1087) 0.14.0
Erik [Sun, 8 Nov 2020 19:50:12 +0000 (11:50 -0800)] 
Version 0.14.0 (#1087)

* Version 0.14.0 release preparation: write release-notes and version bump.

4 years agoAllow usage of functools.partial async handlers (#984)
Vlad Stefan Munteanu [Sun, 8 Nov 2020 01:33:11 +0000 (03:33 +0200)] 
Allow usage of functools.partial async handlers (#984)

* Allow usage of async partial methods

* Added test for partial async endpoint

* Double quotes vs single quotes

* Support multiple levels of partials, check Python < 3.8

* Skip coverage for py3.8 branch

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
4 years agoUpdate responses.md (#1080)
Parzival [Wed, 28 Oct 2020 12:55:53 +0000 (18:40 +0545)] 
Update responses.md (#1080)

Small grammar correction.

5 years agoAdd 418 I'm A Teapot status code (#1076)
manuelzander [Thu, 22 Oct 2020 15:15:48 +0000 (16:15 +0100)] 
Add 418 I'm A Teapot status code (#1076)

5 years agofix 793: allow custom async iterator (#1041)
witling [Wed, 21 Oct 2020 18:10:30 +0000 (20:10 +0200)] 
fix 793: allow custom async iterator (#1041)

* fix 793

* custom async generator: implement pr notes

* custom async generator: cleanup dependencies

* update tests

* newline at end of tests

* fix linting

* Update tests/test_responses.py

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
* Update tests/test_responses.py

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
* fix naming for custom generator tests

* comply with pep 492

* Shift streaming tests to be in one place

Co-authored-by: witling <noreply@my.email>
Co-authored-by: Jamie Hewland <jhewland@gmail.com>
5 years agoFriendly spell check in `routing.md` docs. (#1073)
Jeff Astor [Thu, 15 Oct 2020 10:23:52 +0000 (06:23 -0400)] 
Friendly spell check in `routing.md` docs. (#1073)

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
5 years agoAdd type: ignore for aiofiles to make mypy happier (#1072)
Moriyoshi Koizumi [Wed, 14 Oct 2020 20:51:28 +0000 (05:51 +0900)] 
Add type: ignore for aiofiles to make mypy happier (#1072)

* Add type: ignore to make mypy happier

* Tentatively ignore type checking failure until the following patch gets merged

https://github.com/python/typeshed/pull/4650

5 years agoTest on Python 3.9 (#1068)
Jamie Hewland [Wed, 7 Oct 2020 19:58:59 +0000 (21:58 +0200)] 
Test on Python 3.9 (#1068)

* Test on Python 3.9

* Update trove classifiers

5 years agoCreate tasks from coroutines before providing to asyncio.wait (#1066)
Jamie Hewland [Wed, 7 Oct 2020 19:20:55 +0000 (21:20 +0200)] 
Create tasks from coroutines before providing to asyncio.wait (#1066)

5 years agoFix return value of TestClient's __enter__ method (#1064)
Andrey Semakin [Fri, 2 Oct 2020 08:53:40 +0000 (13:53 +0500)] 
Fix return value of TestClient's __enter__ method (#1064)

5 years agoapply pyupgrade --py36-plus (#1048)
Thomas Grainger [Sun, 27 Sep 2020 18:47:51 +0000 (19:47 +0100)] 
apply pyupgrade --py36-plus (#1048)

5 years agoMove lifespan tests out of obsolete middleware test module (#1055)
Jamie Hewland [Fri, 11 Sep 2020 13:26:55 +0000 (15:26 +0200)] 
Move lifespan tests out of obsolete middleware test module (#1055)

* Move lifespan tests out of obsolete middleware test module

* Add test_lifespan_async

5 years agoUse format_exception instead of format_tb (#1031)
Elliana May [Fri, 11 Sep 2020 11:15:50 +0000 (19:15 +0800)] 
Use format_exception instead of format_tb (#1031)

* Use format_exception instead of format_tb

This gives much more information about the exception, including causes, and the exception message itself, in addition to the trackback

* Update test

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
5 years agoconfigure pytest to be stricter (#1040)
Thomas Grainger [Fri, 11 Sep 2020 09:19:47 +0000 (10:19 +0100)] 
configure pytest to be stricter (#1040)

* fix tests/test_datastructures::TestUploadFile PytestCollectionWarning

enhance pytest strictness to catch warnings that would have prevented
thest TestUploadFile file warning

restore cov-report and require 100% coverage

* Apply suggestions from code review

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
* remove cov-fail-under

* Apply suggestions from code review

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
* Apply suggestions from code review

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
* Update setup.cfg

Co-authored-by: Jamie Hewland <jhewland@gmail.com>
Co-authored-by: Jamie Hewland <jhewland@gmail.com>
5 years agoAdd issue templates (#1054)
Jamie Hewland [Thu, 10 Sep 2020 19:30:52 +0000 (21:30 +0200)] 
Add issue templates (#1054)

5 years agoRun coverage check in CI (#1051)
Jamie Hewland [Tue, 8 Sep 2020 06:54:55 +0000 (08:54 +0200)] 
Run coverage check in CI (#1051)

* Run coverage check in CI

* Use the same step name as httpx

5 years agoallow black to pass on v20.8b1 and v19.10b0 (#1049)
Thomas Grainger [Mon, 7 Sep 2020 07:19:20 +0000 (08:19 +0100)] 
allow black to pass on v20.8b1 and v19.10b0 (#1049)

by running black v19.3b0 (we miss you) and then running black v20.8b1

5 years agoUpdate CI scripts to match httpcore (#1043)
Jamie Hewland [Sun, 6 Sep 2020 10:08:07 +0000 (12:08 +0200)] 
Update CI scripts to match httpcore (#1043)

* Update CI scripts to match httpcore

* Run test suite on pushes to master

* Update scripts README

* Don't bother with flake8 extensions for now

* Remove unnecessary PYTHONPATH from build, publish

* test_routing: Use a stub app instead of ellipsis

* Add link to issue about type-checking tests

5 years agoUse and pin black 20 (#1042)
Jamie Hewland [Sat, 5 Sep 2020 13:16:56 +0000 (15:16 +0200)] 
Use and pin black 20 (#1042)

5 years agoBe more lenient with route arguments in AuthencationMiddleware 'requires' decorator...
Hannes Küttner [Sun, 16 Aug 2020 14:24:23 +0000 (16:24 +0200)] 
Be more lenient with route arguments in AuthencationMiddleware 'requires' decorator (#942)

5 years agoInstall dependencies before attempting to publish. (#1030)
Erik [Sat, 15 Aug 2020 03:52:58 +0000 (20:52 -0700)] 
Install dependencies before attempting to publish. (#1030)

5 years agoVersion 0.13.8 (#1026) 0.13.8
Erik [Fri, 14 Aug 2020 03:48:43 +0000 (20:48 -0700)] 
Version 0.13.8 (#1026)

* Version 0.13.8 release

Release notes with following:
- Revert Queue maxsize fix in BaseHTTPMiddleware
- Pathlib Path's now allowed in staticfiles constructor

5 years agoRemove maxsize arg from Queue constructor in BaseHTTPMiddleware (#1028)
Erik [Thu, 13 Aug 2020 12:48:18 +0000 (05:48 -0700)] 
Remove maxsize arg from Queue constructor in BaseHTTPMiddleware (#1028)

5 years agoUse os.PathLike in StaticFiles for directory (#1007)
Kevin Stone [Wed, 5 Aug 2020 23:04:07 +0000 (18:04 -0500)] 
Use os.PathLike in StaticFiles for directory (#1007)

* Use os.PathLike in StaticFiles for directory

This allows using `pathlib.Path` in addition to `str` for configuring
the base directory of the static files in line with how python3.6+
handles filesystem operations.

Fixes #1004

* Fixed `mimetypes.guess_type` not supporting PathLike on py3.7 and below

* Updated staticfiles documentation with `PathLike` param

5 years agoPrepare 0.13.7 release: version bump and release-notes (#1020) 0.13.7
Erik [Wed, 5 Aug 2020 15:07:14 +0000 (08:07 -0700)] 
Prepare 0.13.7 release: version bump and release-notes (#1020)

5 years agoFix high memory usage when using BaseHTTPMiddleware middleware classes and streaming...
Erik [Tue, 4 Aug 2020 23:55:46 +0000 (16:55 -0700)] 
Fix high memory usage when using BaseHTTPMiddleware middleware classes and streaming responses (#1018)

* BaseHTTPMiddleware add maxsize arg to Queue constructor

- Limit queue size to 1 to prevent loading entire streaming response into memory

5 years agoDOCUMENTATION -- Correction in websockets.md (#1011)
Yaakov Belch [Mon, 27 Jul 2020 10:38:02 +0000 (13:38 +0300)] 
DOCUMENTATION -- Correction in websockets.md (#1011)

Correct the exception class from `starlette.websockets.Disconnect` to `starlette.websockets.WebSocketDisconnect`

5 years agoAdd type annotation to WebSocketEndpoint.encoding (#1003)
Dan Trickey [Fri, 24 Jul 2020 10:13:14 +0000 (11:13 +0100)] 
Add type annotation to WebSocketEndpoint.encoding (#1003)

* Add type annotation to WebSocketEndpoint.encoding

* Update endpoints.py

Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
5 years agoFixed typo in websocket doc (#1009)
Justin Yo [Fri, 24 Jul 2020 10:11:10 +0000 (19:11 +0900)] 
Fixed typo in websocket doc (#1009)

Co-authored-by: YeohJerWei <yeohjerwe@gmail.com>
5 years agoVersion 0.13.6 (#1006) 0.13.6
Tom Christie [Mon, 20 Jul 2020 12:12:23 +0000 (13:12 +0100)] 
Version 0.13.6 (#1006)

* Fix staticfiles 404 errors

* Version 0.13.6

5 years agoFix staticfiles 404 errors (#1005)
Tom Christie [Mon, 20 Jul 2020 12:05:55 +0000 (13:05 +0100)] 
Fix staticfiles 404 errors (#1005)

5 years agoVersion 0.13.5 (#1001) 0.13.5
Tom Christie [Fri, 17 Jul 2020 12:41:00 +0000 (13:41 +0100)] 
Version 0.13.5 (#1001)