v2.1.0
- Remove support for Python 3.8, by @bymoye.
- Fix a bug in the
ClientSession, happening when the server returns a response
body without specifyingContent-Lengthand without specifying a
Transfer-Encoding. - Fix a bug in the
ClientSession, happening when a server closes the
connection, and the response content is not set as completed. - Add a default
User-Agentto web requests sent using theClientSession,
the user agent is:python-blacksheep/{__version__}. - Add an async method
raise_for_statusto theResponseobject, which raises
an exception of typeFailedRequestErrorif the response status is not in
the range 200-299. The method is asynchronous because in case of failure
it waits for the response body to be downloaded, to include it in the raised
exception. - Add support for specifying a prefix for the
Router, and for configuring a
global prefix for all routes using the env variableAPP_ROUTE_PREFIX.
If specified, the prefix is applied to all routes registered in the
application router. The prefix is used automatically by the
serve_filesmethod, theget_absolute_url_to_pathmethod, and by the
OpenAPI UI feature, to serve documentation to the correct path.
This feature is useful when exposing applications behind proxies using
path based routing, to maintain the same path between the proxy server and
the BlackSheep application. This is an alternative approach to the one used
by theroot_pathoffered byASGI(still supported inBlackSheep).
ASGIroot_pathand route prefix in BlackSheep are alternative ways to
address the same issue, and should not be used together. - Improve the OpenAPI UI to support router prefixes, and fetching the
specification file using relative links. - Upgrade to
Cythonto3.0.12in the GitHub Workflow. - Handle setuptools warning: SetuptoolsDeprecationWarning: License classifiers are deprecated.
- Improve
pyproject.tomlto usetool.setuptools.packages.find. - Add the missing "utf8" encoding to the
request.pathproperty decode call. - Add a middleware to handle automatic redirects from URLs that do not end with
a "/" towards the same path with a trailing slash. This is useful for
endpoints that serve HTML documents, to ensure that relative URLs in the
response body are correctly resolved
(from blacksheep.server.redirects import get_trailing_slash_middleware). - Add a built-in strategy to handle startup errors and display an error page
when an application fails during initialization, in
blacksheep.server.diagnostics.get_diagnostic_app. Error details are not
displayed by default, but can be displayed setting the environment variable
APP_SHOW_ERROR_DETAILSto a value such as1ortrue. - Use
asyncio_mode=autoforpytest(remove@pytest.mark.asynciodecorators). - Use
Python 3.12to publish the package, in the GitHub Workflow. - Modify the
Applicationobject to instantiate requests in a dedicated method
instantiate_request. This is to better support code that modifies how
incoming requests are created. - Modify the
OpenAPIHandlerclass to support specifying the list ofServer
objects in the constructor. - Update
essentials-openapipinned version, by @stollero. - Bump jinja2 from 3.1.4 to 3.1.6.
- Bump cryptography from 44.0.0 to 44.0.1.
- Remove
pyfrom the list of dependencies inrequirements.txt. - Correct some docstrings.
Where not specified, contributions are from @RobertoPrevato.