Skip to content

Commit

Permalink
Fix #394 (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoPrevato authored Jul 14, 2023
1 parent 18ff88d commit 041ff8b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion blacksheep/contents.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion blacksheep/contents.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 10 additions & 1 deletion tests/test_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

0 comments on commit 041ff8b

Please sign in to comment.