diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cf21506..2af0e1f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0a9] - 2023-07-14 + +- Fixes bug #394, causing the `Content` max body size to be 2147483647 + (C int max value). Reported and fixed by @thomafred + ## [2.0a8] - 2023-07-02 - Add support for `StreamedContent` with specific content length; fixing diff --git a/blacksheep/__init__.py b/blacksheep/__init__.py index ca11d15b..2242c0c3 100644 --- a/blacksheep/__init__.py +++ b/blacksheep/__init__.py @@ -3,7 +3,7 @@ used types to reduce the verbosity of the imports statements. """ __author__ = "Roberto Prevato " -__version__ = "2.0a8" +__version__ = "2.0a9" from .contents import Content as Content from .contents import FormContent as FormContent diff --git a/blacksheep/contents.pxd b/blacksheep/contents.pxd index 0a3731d9..ae341c6d 100644 --- a/blacksheep/contents.pxd +++ b/blacksheep/contents.pxd @@ -8,7 +8,7 @@ cdef class Content: cdef readonly bytes type cdef readonly bytes body - cdef readonly int length + cdef readonly long long length cdef class StreamedContent(Content): diff --git a/blacksheep/contents.pyx b/blacksheep/contents.pyx index 04dd2f2d..a2dc47d1 100644 --- a/blacksheep/contents.pyx +++ b/blacksheep/contents.pyx @@ -31,7 +31,7 @@ cdef class StreamedContent(Content): self, bytes content_type, object data_provider, - int data_length = -1 + long long data_length = -1 ): self.type = content_type self.body = None diff --git a/tests/test_contents.py b/tests/test_contents.py index f0c805cd..96c74741 100644 --- a/tests/test_contents.py +++ b/tests/test_contents.py @@ -2,11 +2,12 @@ import pytest -from blacksheep import JSONContent, Request, StreamedContent +from blacksheep import JSONContent, Request from blacksheep.contents import ( FormPart, HTMLContent, MultiPartFormData, + StreamedContent, TextContent, parse_www_form, write_www_form_urlencoded, @@ -323,3 +324,11 @@ async def test_write_request_body_only(req: Request, expected_chunks: List[bytes received_chunks.append(chunk) assert received_chunks == expected_chunks + + +@pytest.mark.parametrize("size", [0, 2000, 2147483647, 9e18]) +def test_content_size(size): + async def gen(): + yield b"" + + StreamedContent(b"text/plain", gen, size)