Skip to content

Falcon response binary format support #669

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion openapi_core/contrib/falcon/responses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""OpenAPI core contrib falcon responses module"""
from itertools import tee

from falcon.response import Response
from werkzeug.datastructures import Headers

Expand All @@ -12,7 +14,12 @@ def __init__(self, response: Response):
@property
def data(self) -> str:
if self.response.text is None:
return ""
if self.response.stream is None:
return ""
resp_iter1, resp_iter2 = tee(self.response.stream)
self.response.stream = resp_iter1
content = b"".join(resp_iter2)
return content
assert isinstance(self.response.text, str)
return self.response.text

Expand Down