Skip to content

Body for RedirectResponse #2477

@mrkovalchuk

Description

@mrkovalchuk

Good day.

I found some conflict (as I see it) between RedirectResponse class and openapi schema.

class RedirectResponse(Response):
    def __init__(
        self,
        url: typing.Union[str, URL],
        status_code: int = 307,
        headers: dict = None,
        background: BackgroundTask = None,
    ) -> None:
        super().__init__(
            content=b"", status_code=status_code, headers=headers, background=background
        )
        self.headers["location"] = quote_plus(str(url), safe=":/%#?&=@[]!$&'()*+,;")

We can't define a content. But only 304 status code (of the redirect codes) really can't have a body.

This fact and STATUS_CODES_WITH_NO_BODY = {..., 304} makes a trouble with openapi schema validation.

May be, we should allow set a content with check for the 304 status_code (and nullify content if it is)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions