-
Notifications
You must be signed in to change notification settings - Fork 137
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
Support bare wsgi request #55
Conversation
self.assertEqual(data['url'], 'http://example.com/api/test?format=json¶m1=value1¶m2=value2') | ||
self.assertEqual(data['user_ip'], '127.0.0.1') | ||
self.assertDictEqual(data['GET'], {'format': 'json', 'param1': 'value1', 'param2': 'value2'}) | ||
self.assertDictEqual(data['headers'], {'Connection': 'close', 'Host': 'example.com', 'User-Agent': 'Agent'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing an assertion for the request method
Thanks @asnyatkov! See comments above. Generally looks good; will be happy to merge once the tests are passing. |
'method': request.get('REQUEST_METHOD'), | ||
} | ||
if 'QUERY_STRING' in request: | ||
request_data['GET'] = urlparse.parse_qs(request['QUERY_STRING'], keep_blank_values=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be request_data[request_data['method'].upper()] = ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's correct as-is -- the QUERY_STRING is always the "GET" params. POST data goes in the body, not the query string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use request_data['query']
to store this data. request_data['GET']
is a bit misleading IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just followed what all other request builders do. request_data['GET'] is used in _scrub_request_data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Touché. Ok. Leave it as-is since changing this will require a minor version bump.
Thanks for the PR. I've tested and this should be good to merge after my comment about the method name. |
except ValueError: | ||
length = 0 | ||
input = request.get('wsgi.input') | ||
if length and input and input.seekable(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting the following Exception while POSTing to a simple wsgi server:
AttributeError: '_fileobject' object has no attribute 'seekable'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add attribute check and a unit test.
#52