* supply asgi_extensions to TestClient
* Add WebSocket.send_response()
* Add response support for WebSocket testclient
* fix test for filesystem line-endings
* lintint
* support websocket.http.response extension by default
* Improve coverate
* Apply suggestions from code review
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
* Undo unrelated change
* fix incorrect error message
* Update starlette/websockets.py
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
* formatting
* Re-introduce close-code and close-reason to WebSocketReject
* Make sure the "websocket.connect" message is received in tests
* Deliver a websocket.disconnect message to the app even if it closes/rejects itself.
* Add test for filling out missing `websocket.disconnect` code
* Add rejection headers. Expand tests.
* Fix types, headers in message are `bytes` tuples.
* Minimal WebSocket Denial Response implementation
* Revert "Minimal WebSocket Denial Response implementation"
This reverts commit 7af10ddcfa5423c18953cf5d1317cb5aa30a014c.
* Rename to send_denial_response and update documentation
* Remove the app_disconnect_msg. This can be added later in a separate PR
* Remove status code 1005 from this PR
* Assume that the application has tested for the extension before sending websocket.http.response.start
* Rename WebSocketReject to WebSocketDenialResponse
* Remove code and status from WebSocketDenialResponse.
Just send a regular WebSocketDisconnect even when connection is rejected with close()
* Raise an exception if attempting to send a http response and server does not support it.
* WebSocketDenialClose and WebSocketDenialResponse
These are both instances of WebSocketDenial.
* Update starlette/testclient.py
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
* Revert "WebSocketDenialClose and WebSocketDenialResponse"
This reverts commit 71b76e3f1c.
* Rename parameters, member variables
* Use httpx.Response as the base for WebSocketDenialResponse.
* Apply suggestions from code review
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
* Update sanity check message
* Remove un-needed function
* Expand error message test regex
* Add type hings to test methods
* Add doc string to test.
* Fix mypy complaining about mismatching parent methods.
* nitpick & remove test
* Simplify the documentation
* Update starlette/testclient.py
* Update starlette/testclient.py
* Remove an unnecessary test
* there is no special "close because of rejection" in the testclient anymore.
---------
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
* If no extra headers are passed, set it to an empty list
* Test websocket.accept() with no additional headers
* Update starlette/websockets.py
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
* Update tests/test_websockets.py
Co-authored-by: Amin Alaee <mohammadamin.alaee@gmail.com>
* Update tests/test_websockets.py
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Amin Alaee <mohammadamin.alaee@gmail.com>
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>
* 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>
* Add status.py for http and websocket status code with descriptive
variable names.
* Fix import of status
* Add status usage to tests
* change wsconnect to websocket_connect
* Update with master
* WebSockets support
* WebSockets support
* WebSockets support
* Black formatting
* Add missing descriptions against websocket test session docs
* Add missing descriptions against websocket test session docs
* Add note on session.send() / session.receive()