This release contains several refinements to request validation and error handling, along with some tweaks to response handling for static and downloadable files.
Due to popular demand, ~falcon.testing.TestClient
and ~falcon.testing.ASGIConductor
now expose convenience shorthand aliases for the simulate_*
methods, i.e., ~falcon.testing.TestClient.simulate_get
is now also available as ~falcon.testing.TestClient.get
, etc. (#1806)
Some important bugs were also fixed to ensure applications properly clean up response streams and do not hang when reading request bodies that are streamed using chunked transfer encoding.
This release also adds support for CPython 3.10 and deprecates CPython 3.6.
- CPython 3.10 is now fully supported. (#1966)
- Support for Python 3.6 is now deprecated and will be removed in Falcon 4.0.
- As with the previous release, Python 3.5 support remains deprecated and will no longer be supported in Falcon 4.0.
- The
jsonschema.validate <falcon.media.validators.jsonschema.validate>
decorator now raises an instance of~falcon.MediaValidationError
instead of the generic~falcon.HTTPBadRequest
for request media validation failures. Although the default behavior is kept unaltered in a backwards-compatible fashion (as the specialized exception subclasses the generic one), but it can now be easily customized by adding an error handler for the new class. (#1320) - Due to popular demand,
~falcon.testing.TestClient
and~falcon.testing.ASGIConductor
now expose convenience shorthand aliases for thesimulate_*
methods, i.e.,~falcon.testing.TestClient.simulate_get
is now also available as~falcon.testing.TestClient.get
, etc. (#1806) The
Request.range <falcon.Request.range>
property now has stricter validation:- When parsing a byte-range-spec with a last-byte-pos, it must be greater than or equal to first-byte-pos.
- When parsing a suffix-byte-range-spec, suffix-length must be positive.
Static routes <falcon.App.add_static_route>
now supportRange
requests. This is useful for streaming media and resumable downloads. (#1858)- Added a
Response.viewable_as <falcon.Response.viewable_as>
property; this is similar toResponse.downloadable_as <falcon.Response.downloadable_as>
but with an "inline" disposition type so the response will still be displayed in the browser. (#1951) - Added support for passing
pathlib.Path
objects as directory in the~falcon.App.add_static_route
method on all targeted Python versions. (#1962) Static routes <falcon.App.add_static_route>
now set theContent-Length
header indicating a served file's size (or length of the rendered content range). (#1991)- When called with deprecated positional arguments, methods and class initializers (such as
falcon.errors.HTTPError
) will now emit a user-friendlier warning indicating the fully qualified name of the method in question. (#2010)
- If provided, the
close()
method of an ASGIresp.stream <falcon.asgi.Response.stream>
is now guaranteed to be called even in the case of an exception raised while iterating over the data. (#1943) - Previously, files could be left open when serving via an ASGI static route (depending on the underlying GC implementation). This has been fixed so that a file is closed explicitly after rendering the response. (#1963)
- When a request was streamed using the chunked transfer encoding (with no
Content-Length
known in advance), iterating overreq.stream <falcon.asgi.Request.stream>
could hang until the client had disconnected. This bug has been fixed, and iteration now stops upon receiving the last body chunk as expected. (#2024)
- The
~falcon.routing.compile_uri_template
utility method has been deprecated and will be removed in Falcon 4.0. This function was only employed in the early versions of the framework, and is expected to have been fully supplanted by the~falcon.routing.CompiledRouter
. In the unlikely case it is still in active use, its source code can be simply copied into an affected application. (#1967)
Many thanks to all the contributors for this release!