Skip to content

Commit 59ed6a8

Browse files
Merge pull request #786 from hugapi/feature/fix-issue-784
Feature/fix issue 784
2 parents c12a78b + d99717e commit 59ed6a8

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Ideally, within a virtual environment.
1212

1313
Changelog
1414
=========
15-
### 2.5.1 - TBD
15+
### 2.5.1 hotfix - TBD,
16+
- Fixed issue #784 - POST requests broken on 2.5.0
1617
- Optimizations and simplification of async support, taking advantadge of Python3.4 deprecation.
1718
- Fix issue #785: Empty query params are not ignored on 2.5.0
1819
- Added support for modifying falcon API directly on startup

hug/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ def gather_parameters(self, request, response, context, api_version=None, **inpu
705705
input_parameters.update(request.params)
706706

707707
if self.parse_body and request.content_length:
708-
body = request.stream
708+
body = request.bounded_stream
709709
content_type, content_params = parse_content_type(request.content_type)
710710
body_formatter = body and self.inputs.get(
711711
content_type, self.api.http.input_format(content_type)

tests/test_full_request.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""tests/test_full_request.py.
2+
3+
Test cases that rely on a command being ran against a running hug server
4+
5+
Copyright (C) 2016 Timothy Edmund Crosley
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
10+
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or
13+
substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
16+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
18+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19+
OTHER DEALINGS IN THE SOFTWARE.
20+
21+
"""
22+
import platform
23+
import time
24+
from subprocess import Popen
25+
26+
import pytest
27+
import requests
28+
29+
import hug
30+
31+
TEST_HUG_API = """
32+
import hug
33+
34+
35+
@hug.post("/test", output=hug.output_format.json)
36+
def post(body, response):
37+
print(body)
38+
return {'message': 'ok'}
39+
"""
40+
41+
42+
@pytest.mark.skipif(platform.python_implementation() == "PyPy", reason="Can't run hug CLI from travis PyPy")
43+
def test_hug_post(tmp_path):
44+
hug_test_file = (tmp_path / "hug_postable.py")
45+
hug_test_file.write_text(TEST_HUG_API)
46+
hug_server = Popen(['hug', '-f', str(hug_test_file), '-p', '3000'])
47+
time.sleep(5)
48+
requests.post('http://127.0.0.1:3000/test', {'data': 'here'})
49+
hug_server.kill()

0 commit comments

Comments
 (0)