diff --git a/integration_tests/base_routes.py b/integration_tests/base_routes.py index ec47f1c1d..81725a61d 100644 --- a/integration_tests/base_routes.py +++ b/integration_tests/base_routes.py @@ -530,8 +530,8 @@ def sync_decorator_view(): def get(): return "Hello, world!" - def post(request): - body = bytearray(request["body"]).decode("utf-8") + def post(request: Request): + body = request.body.content return {"status_code": 200, "body": body} @@ -540,8 +540,8 @@ def async_decorator_view(): async def get(): return "Hello, world!" - async def post(request): - body = bytearray(request["body"]).decode("utf-8") + async def post(request: Request): + body = request.body.content return {"status_code": 200, "body": body} diff --git a/integration_tests/test_binary_output.py b/integration_tests/test_binary_output.py index 129da8f63..f66eb5b6f 100644 --- a/integration_tests/test_binary_output.py +++ b/integration_tests/test_binary_output.py @@ -1,6 +1,6 @@ import pytest -from http_methods_helpers import get +from helpers.http_methods_helpers import get BASE_URL = "http://127.0.0.1:8080" diff --git a/integration_tests/test_middlewares.py b/integration_tests/test_middlewares.py index 0b7d83298..214f6e4cd 100644 --- a/integration_tests/test_middlewares.py +++ b/integration_tests/test_middlewares.py @@ -6,8 +6,6 @@ @pytest.mark.parametrize("function_type", ["sync", "async"]) def test_middlewares(function_type: str, session): r = get(f"/{function_type}/middlewares") - assert "before" in r.headers - assert r.headers["before"] == f"{function_type}_before_request" assert "after" in r.headers assert r.headers["after"] == f"{function_type}_after_request" assert r.text == f"{function_type} middlewares after" diff --git a/integration_tests/views/async_view.py b/integration_tests/views/async_view.py index 644674303..761332982 100644 --- a/integration_tests/views/async_view.py +++ b/integration_tests/views/async_view.py @@ -1,9 +1,12 @@ +from robyn.robyn import Request + + def AsyncView(): async def get(): return "Hello, world!" - async def post(request): - body = bytes(request["body"]).decode("utf-8") + async def post(request: Request): + body = request.body.content return { "status": 200, "body": body, diff --git a/integration_tests/views/sync_view.py b/integration_tests/views/sync_view.py index 2aec64f43..0229f95a9 100644 --- a/integration_tests/views/sync_view.py +++ b/integration_tests/views/sync_view.py @@ -1,9 +1,12 @@ +from robyn.robyn import Request + + def SyncView(): def get(): return "Hello, world!" - def post(request): - body = bytes(request["body"]).decode("utf-8") + def post(request: Request): + body = request.body.content return { "status": 200, "body": body, diff --git a/src/server.rs b/src/server.rs index b5076cde4..5229d4143 100644 --- a/src/server.rs +++ b/src/server.rs @@ -373,7 +373,11 @@ async fn index( Response::not_found(&request.headers) }; - response.headers.extend(request.headers.into_iter()); + response.headers.extend( + global_response_headers + .iter() + .map(|elt| (elt.key().clone(), elt.value().clone())), + ); // After middleware response = match middleware_router.get_route(&MiddlewareRoute::AfterRequest, req.uri().path()) {