Commit Graph

15 Commits

Author SHA1 Message Date
Kristján Valur Jónsson 93e74a4d2f
Support the WebSocket Denial Response ASGI extension (#2041)
* 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>
2024-02-04 20:16:10 +00:00
Marcelo Trylesinski 9450edf282
Document iter methods for WebSockets (#2011) 2023-01-18 16:16:20 +01:00
Amin Alaee 34d9f0f10f
Add reason to WebSocket closure (#1417)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2022-01-22 17:11:32 +01:00
matiuszka 9d686a7125
Additional headers for WS `accept` message. (#1361)
* Additional headers for WS accept message.

* Update tests/test_websockets.py

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>

* fixup! Additional headers for WS accept message.

* Update tests/test_websockets.py

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2022-01-06 11:55:29 +01:00
Denis Eliseev 2b83c8cea6
Remove self from websocker example app (#1103)
Co-authored-by: Jamie Hewland <jhewland@gmail.com>
2021-02-02 11:01:03 +00:00
Yaakov Belch 1db80104f7
DOCUMENTATION -- Correction in websockets.md (#1011)
Correct the exception class from `starlette.websockets.Disconnect` to `starlette.websockets.WebSocketDisconnect`
2020-07-27 11:38:02 +01:00
Justin Yo 4935397611
Fixed typo in websocket doc (#1009)
Co-authored-by: YeohJerWei <yeohjerwe@gmail.com>
2020-07-24 12:11:10 +02:00
Kevin Tewouda e1b045cea7
Fixed typos in documentation (#956)
Co-authored-by: le_woudar <kevin.tewouda@gandi.net>
2020-05-28 14:11:22 +01:00
Tom Christie 9e962e79f2 Update WebSocket docs. Closes #536. 2019-06-10 09:18:08 +01:00
Tom Christie 1ee194739f
WebSockets now default to sending JSON using text dataframes (#349) 2019-01-25 15:27:39 +00:00
Tom Christie d5c798e6b8
Example ASGI apps now ensure scope['type'] is expected message type. (#348) 2019-01-25 14:40:33 +00:00
Tom Christie 8da0f00fe7
Routing interface (#144)
* Path -> Route, PathPrefix -> Mount

* Route, WebSocketRoute, Mount

* Use Route(endpoint=...), not Route(app=...)

* Bare minimum docs update

* Add url_for

* request.path_params and session.path_params

* Version 0.6.0
2018-10-29 09:22:45 +00:00
Jordan Eremieff f4fe0ec312 Name changes (#55)
* Rename View -> HTTPEndpoint

* Rename views doc file -> endpoints

* Rename request/response files -> requests/responses, update imports, update docs

* Rename WebSocketSession -> WebSocket, rename session -> websocket in docs

* Full module imports in tests and source, removing imports from __init__ file

* Fix name in testclient doc
2018-09-05 10:29:04 +01:00
Tom Christie 2002eb1bd2 Drop licence footer from page content 2018-08-29 11:31:08 +01:00
Jeff Buttars bb6a8fb7c9 Initial conversion of README.md to mkdocs 2018-08-28 07:58:03 -06:00