Skip to content

Commit

Permalink
fix: enables json as valid redirect response. (#1908)
Browse files Browse the repository at this point in the history
* fix: enables `xml` and `json` as valid redirect response.

* fix: enable CSS as a valid redirect media type

* fix: updated test case

* Remove XML and CSS from redirect types for now.
  • Loading branch information
cofin authored Jul 2, 2023
1 parent 55ce3a6 commit dd9f295
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion litestar/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ONE_MEGABYTE = 1024 * 1024
OPENAPI_NOT_INITIALIZED = "Litestar has not been instantiated with OpenAPIConfig"
REDIRECT_STATUS_CODES = {301, 302, 303, 307, 308}
REDIRECT_ALLOWED_MEDIA_TYPES = {MediaType.TEXT, MediaType.HTML}
REDIRECT_ALLOWED_MEDIA_TYPES = {MediaType.TEXT, MediaType.HTML, MediaType.JSON}
RESERVED_KWARGS = {"state", "headers", "cookies", "request", "socket", "data", "query", "scope", "body"}
SCOPE_STATE_DEPENDENCY_CACHE: Literal["dependency_cache"] = "dependency_cache"
SCOPE_STATE_NAMESPACE: Literal["__litestar__"] = "__litestar__"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_response/test_redirect_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def app(scope: "Scope", receive: "Receive", send: "Send") -> None:

def test_redirect_response_media_type_validation() -> None:
with pytest.raises(ImproperlyConfiguredException):
ASGIRedirectResponse(path="/", media_type="application/json")
ASGIRedirectResponse(path="/", media_type="application/mspgpack")


@pytest.mark.parametrize(
Expand Down

0 comments on commit dd9f295

Please sign in to comment.