Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need to make sure JsonApiException().status is integer #205

Open
qweasdzxcpkh opened this issue Apr 29, 2021 · 0 comments
Open

need to make sure JsonApiException().status is integer #205

qweasdzxcpkh opened this issue Apr 29, 2021 · 0 comments

Comments

@qweasdzxcpkh
Copy link

Hi, i am using fastapi to deploy my backend, and using this repo to help my api code create.
i found a problem when fastapi work with this repo, fastapi will split the Response().status with ' ', like:

status_code_string, _ = status.split(" ", 1)

then i watch the source code with flask, it will make confuse with '500' and 500.
the Response().status setter look like this:

class BaseResponse(object):
    @property
    def status_code(self):
        """The HTTP status code as a number."""
        return self._status_code

    @status_code.setter
    def status_code(self, code):
        self._status_code = code
        try:
            self._status = "%d %s" % (code, HTTP_STATUS_CODES[code].upper())
        except KeyError:
            self._status = "%d UNKNOWN" % code

    @property
    def status(self):
        """The HTTP status code as a string."""
        return self._status

    @status.setter
    def status(self, value):
        try:
            self._status = to_native(value)
        except AttributeError:
            raise TypeError("Invalid status argument")

        try:
            self._status_code = int(self._status.split(None, 1)[0])
        except ValueError:
            self._status_code = 0
            self._status = "0 %s" % self._status
        except IndexError:
            raise ValueError("Empty status argument")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant