Skip to content

v2.1.0

Choose a tag to compare

@RobertoPrevato RobertoPrevato released this 23 Mar 16:46
· 72 commits to main since this release
277cece
  • Remove support for Python 3.8, by @bymoye.
  • Fix a bug in the ClientSession, happening when the server returns a response
    body without specifying Content-Length and 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-Agent to web requests sent using the ClientSession,
    the user agent is: python-blacksheep/{__version__}.
  • Add an async method raise_for_status to the Response object, which raises
    an exception of type FailedRequestError if 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 variable APP_ROUTE_PREFIX.
    If specified, the prefix is applied to all routes registered in the
    application router. The prefix is used automatically by the
    serve_files method, the get_absolute_url_to_path method, 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 the root_path offered by ASGI (still supported in BlackSheep).
    ASGI root_path and 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 Cython to 3.0.12 in the GitHub Workflow.
  • Handle setuptools warning: SetuptoolsDeprecationWarning: License classifiers are deprecated.
  • Improve pyproject.toml to use tool.setuptools.packages.find.
  • Add the missing "utf8" encoding to the request.path property 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_DETAILS to a value such as 1 or true.
  • Use asyncio_mode=auto for pytest (remove @pytest.mark.asyncio decorators).
  • Use Python 3.12 to publish the package, in the GitHub Workflow.
  • Modify the Application object to instantiate requests in a dedicated method
    instantiate_request. This is to better support code that modifies how
    incoming requests are created.
  • Modify the OpenAPIHandler class to support specifying the list of Server
    objects in the constructor.
  • Update essentials-openapi pinned version, by @stollero.
  • Bump jinja2 from 3.1.4 to 3.1.6.
  • Bump cryptography from 44.0.0 to 44.0.1.
  • Remove py from the list of dependencies in requirements.txt.
  • Correct some docstrings.

Where not specified, contributions are from @RobertoPrevato.