diff --git a/CHANGELOG.md b/CHANGELOG.md index cd0cde26..12638eef 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). +## [1.2.18] - 2023-07-14 :no_entry: + +- Fixes bug #394, causing the `Content` max body size to be 2147483647 + (C int max value). Reported and fixed by @thomafred + ## [1.2.17] - 2023-06-18 :ambulance: - Fixes `TypeError` when writing a request without host header. 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 160ca02d..158ec83e 100644 --- a/blacksheep/contents.pyx +++ b/blacksheep/contents.pyx @@ -29,7 +29,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/setup.py b/setup.py index 05188080..4688c6e5 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ def readme(): setup( name="blacksheep", - version="1.2.17", + version="1.2.18", description="Fast web framework for Python asyncio", long_description=readme(), long_description_content_type="text/markdown", 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)