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

[Bug]: Chunked request in requestes #580

Open
jitka opened this issue May 25, 2023 · 1 comment
Open

[Bug]: Chunked request in requestes #580

jitka opened this issue May 25, 2023 · 1 comment
Labels

Comments

@jitka
Copy link
Contributor

jitka commented May 25, 2023

Actual Behavior

Raise exception when tried validate chunked request

Expected Behavior

Buffer request and use for validation

Steps to Reproduce

validate chunked request

OpenAPI Core Version

0.17.1

OpenAPI Core Integration

requests

Affected Area(s)

No response

References

No response

Anything else we need to know?

FIX:

class RequestsOpenAPIRequestFix(RequestsOpenAPIRequest):
    def __init__(self, *args):
        super().__init__(*args)
        self._body_buffer = ''

    @property
    def mimetype(self) -> str:
        return super().mimetype.split(';')[0]

    @property
    def body(self) -> Optional[str]:
        if isinstance(self.request.body, types.GeneratorType):
            for part in self.request.body:
                self._body_buffer += part.decode('utf-8')
            return self._body_buffer
        if self.mimetype.startswith('image'):
            return None
        return super().body

Would you like to implement a fix?

None

@jitka jitka added the kind/bug Indicates an issue label May 25, 2023
@p1c2u
Copy link
Collaborator

p1c2u commented Oct 21, 2023

This will require backward incompatible change in request objet api. We will need to use raw binary request body/response data (+ binary iterator) instead of text/string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants