Commit Graph

15 Commits

Author SHA1 Message Date
赖信涛 8e30f073f0 Do not read file for HEAD method on StaticFiles (#176)
* Do not read file for HEAD method on StaticFiles

* bugfix left in FileResponse

* add test for StaticFiles HEAD method

* restore aiofiles'open after testcase

* format code using black

* Send "http.response.body" instead of disconnect.

body default to b"";
more_body default to False;

fix testcase.

* rebase master, revert background task back

* update param name, send_header_only -> method

* No need to instantiate a new Request, just use scope

* style code using black
2018-11-08 16:59:00 +00:00
Alexander Botello 150c7092e5 StaticFiles will check if directory exists upon instantiation (#195)
* Add check_dir parameter

* Add test coverage for check_dir

* Update documentation

* linting

* Remove extra space
2018-11-08 09:33:20 +00:00
Tom Christie bcf876c686
Use isort for consistent import ordering (#156) 2018-10-29 14:46:42 +00:00
Alexander Botello cdb08bc644 Drop support for `StaticFile` (#145)
* Add runtime checks inside FileResponse w/ tests

* Drop support of StaticFile

* update documentation
2018-10-28 18:04:17 +00:00
Tom Christie 139753f857
Add support for `app.on_event("startup")` and `app.on_event("cleanup")`. (#98)
* Push black linting into ./scripts/test Fix some annotations etc.

* Skip black on 3.7

* Fix script

* Blergh. Shell equality tests are weird

* Attempt to fix equality check

* Document 'allow_origin_regex'

* Support app.on_event('startup') and app.on_event('cleanup')

* Nicer decorator handling for on_event

* Add documentation for app.on_event()
2018-10-09 15:47:51 +01:00
Marcos Schroh d36499526d Missing annotations added on staticfiles module (#70)
* fix(Missing annotation): missing annotations added on staticfiles module.

* fix(staticfiles annotations): annotations fixed.

* refactor(staticfiles): only instanciate a class when is necessary.
2018-10-02 19:06:34 +01: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 67d95fcfa7
Exception handling (#54)
* Exception handling

* Black formatting

* Add exception handling to App

* Handle cases where exception raised but response already started

* Order exception handler lookup by class inheritance

* Handle 404/405 as responses without App, or exceptions with it.

* Only use TestClient(app, raise_exceptions=False) explicitly inside test cases

* Documentation for ExceptionMiddleware

* Drop error_handler/exception_handler distinction.

* Finesse and document TestClient(app, raise_server_exceptions=False)

* Refactoring to make debug responses easier to obtain from elsewhere in code

* Use named status_code argument in example

* Clean up raise_server_errors usage in tests

* Consistent title-casing in HTTP reason phrases

* Black formatting

* Add WebSocketClose close. Omit message-body on 204, 304 exception cases.

* Black formatting

* Add 'debug' flag to App and ExceptionMiddleware

* Support app.debug

* Document debug mode

* Documenting debug
2018-09-04 11:52:29 +01:00
Tom Christie 8245768f81
Use 405 for Method Not Allowed (#53) 2018-08-30 14:42:39 +01:00
Simon Willison 37d9d00655 Correctly handle static files larger than 4096 bytes (#33)
* Fixed bug in FileResponse with files larger than 4096 bytes (single message chunk)
* Failing test for static file larger than 4096 bytes
2018-07-26 14:41:05 +01:00
Tom Christie e3d090b359 Black formatting 2018-07-12 17:07:20 +01:00
Tom Christie 70dd70a4d4 Test for StaticFiles directory breakout protection 2018-07-12 16:29:54 +01:00
Tom Christie 755de3fa09 Black formatting 2018-07-12 13:47:23 +01:00
Tom Christie 6259df6e7a Configuration checks for StaticFiles 2018-07-12 13:41:46 +01:00
Tom Christie 2ed6768352 Add StaticFile and StaticFiles ASGI applications 2018-07-12 13:13:44 +01:00