Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add code explanation
  • Loading branch information
Tomasz Trębski authored and kornicameister committed Jul 9, 2019
commit 8b52da5eeadaf5b6ad05188a0a40679a9c742c38
14 changes: 8 additions & 6 deletions connexion/apis/aiohttp_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ def get_request(cls, req):
logger.debug(
'Getting data and status code',
extra={
# has_body | can_raed_body report if
# has_body | can_read_body report if
# body has been read or not
# body_exists refers to underlying stream of data
'has_body': req.body_exists,
'body_exists': req.body_exists,
'can_ready_body': req.can_read_body,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here -> can_read_body

'content_type': content_type,
'url': url,
Expand All @@ -286,9 +286,13 @@ def get_request(cls, req):
body = None

# if request is not multipart, `data` will be empty dict
# and stream will not be consumed
post_data = yield from req.post()

# set those up beforehand, they are needed anyway
files = {}
form = {}

if post_data:
logger.debug('Reading multipart data from request')
for k, v in post_data.items():
Expand All @@ -300,10 +304,8 @@ def get_request(cls, req):
except AttributeError:
files[k] = [files[k], v]
elif not isinstance(v, web.FileField):
# why do I have to return non file fields as an array?
# If I don't everything goes off the clock in
# connexion.decorators.uri_parsing.OpenAPIURIParser#resolve_form
# string values like 'test' are becoming 't,e,s,t'
# put normal fields as an array, that's how werkzeug does that for Flask
# and that's what Connexion expects in its processing functions
form[k] = [v]
body = b''
else:
Expand Down