Skip to content

Commit

Permalink
3.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
herumes committed May 29, 2024
1 parent a778cac commit 0a0f321
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ annotate:
cython shuttleasgi/baseapp.pyx -a


build: test
build:
python -m build


build2:
python setup.py bdist_wheel


prepforbuild:
pip install --upgrade build

Expand All @@ -49,7 +53,7 @@ testrelease:
twine upload -r testpypi dist/*


release: clean compile artifacts
release: clean compile annotate prepforbuild build build2
twine upload -r pypi dist/*


Expand Down
2 changes: 1 addition & 1 deletion shuttleasgi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

__author__ = "Roberto Prevato <roberto.prevato@gmail.com>"
__version__ = "3.0.1"
__version__ = "3.0.6"

from .contents import Content as Content
from .contents import FormContent as FormContent
Expand Down
4 changes: 2 additions & 2 deletions shuttleasgi/messages.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ cdef class Message:
if not self.declares_json():
return None

text = await self.text()
text = await self.read()

if text is None or text == "":
if text is None or text == b"":
return None

try:
Expand Down
4 changes: 3 additions & 1 deletion shuttleasgi/server/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from shuttleasgi.exceptions import BadRequest
from shuttleasgi.server.websocket import WebSocket
from shuttleasgi.url import URL
from orjson import loads

T = TypeVar("T")
TypeOrName = Union[Type, str]
Expand Down Expand Up @@ -543,7 +544,8 @@ def matches_content_type(self, request: Request) -> bool:
return request.declares_json()

async def read_data(self, request: Request) -> Any:
return await request.json()
raw = await request.read()
return loads(raw)


JsonBinder = JSONBinder
Expand Down
4 changes: 2 additions & 2 deletions shuttleasgi/server/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ def json(self, data, status: int = 200) -> Response:
"""
return json(data, status)

def pretty_orjson(self, data: Any, status: int = 200, indent: int = 2) -> Response:
def pretty_orjson(self, data: Any, status: int = 200, headers = None) -> Response:
"""
Returns a response with indented application/json content,
and given status (default HTTP 200 OK).
"""
return pretty_orjson(data, status=status, indent=indent)
return pretty_orjson(data, status=status, headers=headers)

def text(self, value: str, status: int = 200) -> Response:
"""
Expand Down
4 changes: 2 additions & 2 deletions shuttleasgi/server/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ def json(data: Any, status: int = 200) -> Response:
def pretty_orjson(
data: Any,
status: int = 200,
indent: int = 2,
headers = None,
) -> Response:
"""
Returns a response with indented application/json content,
and given status (default HTTP 200 OK).
"""
return Response(
status,
None,
headers,
Content(
b"application/json",
json_settings.raw_pretty_dumps(data),
Expand Down

0 comments on commit 0a0f321

Please sign in to comment.