diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 0f26e492..f066861d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.4.2 +current_version = 2.4.3 [bumpversion:file:.env] diff --git a/.env b/.env index 7170712c..14674146 100644 --- a/.env +++ b/.env @@ -11,7 +11,7 @@ fi export PROJECT_NAME=$OPEN_PROJECT_NAME export PROJECT_DIR="$PWD" -export PROJECT_VERSION="2.4.2" +export PROJECT_VERSION="2.4.3" if [ ! -d "venv" ]; then if ! hash pyvenv 2>/dev/null; then diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d4534f7..11daf45b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ Ideally, within a virtual environment. Changelog ========= +### 2.4.3 [hotfix] - March 17, 2019 +- Fix issue #737 - latest hug release breaks meinheld worker setup + ### 2.4.2 - March 16, 2019 - Python 3.7 support improvements - No longer test against Python 3.4 - aimed for full deprecation in Hug 3.0.0 diff --git a/hug/_version.py b/hug/_version.py index 4d6093d1..413dfc5f 100644 --- a/hug/_version.py +++ b/hug/_version.py @@ -21,4 +21,4 @@ """ from __future__ import absolute_import -current = "2.4.2" +current = "2.4.3" diff --git a/hug/input_format.py b/hug/input_format.py index 79d3a695..cbbdcf17 100644 --- a/hug/input_format.py +++ b/hug/input_format.py @@ -68,16 +68,13 @@ def urlencoded(body, charset='ascii', **kwargs): @content_type('multipart/form-data') -def multipart(body, **header_params): +def multipart(body, content_length=0, **header_params): """Converts multipart form data into native Python objects""" + header_params.setdefault('CONTENT-LENGTH', content_length) if header_params and 'boundary' in header_params: if type(header_params['boundary']) is str: header_params['boundary'] = header_params['boundary'].encode() - body_content_length = getattr(body, 'content_length', None) - if body_content_length: - header_params['CONTENT-LENGTH'] = body_content_length - form = parse_multipart((body.stream if hasattr(body, 'stream') else body), header_params) for key, value in form.items(): if type(value) is list and len(value) is 1: diff --git a/hug/interface.py b/hug/interface.py index 9f0c3e7e..f4f8ede2 100644 --- a/hug/interface.py +++ b/hug/interface.py @@ -604,11 +604,10 @@ def gather_parameters(self, request, response, context, api_version=None, **inpu if self.parse_body and request.content_length: body = request.stream - body.content_length = request.content_length content_type, content_params = parse_content_type(request.content_type) body_formatter = body and self.inputs.get(content_type, self.api.http.input_format(content_type)) if body_formatter: - body = body_formatter(body, **content_params) + body = body_formatter(body, content_length=request.content_length, **content_params) if 'body' in self.all_parameters: input_parameters['body'] = body if isinstance(body, dict): diff --git a/setup.py b/setup.py index 1f27fe6a..f18f96f2 100755 --- a/setup.py +++ b/setup.py @@ -86,7 +86,7 @@ def list_modules(dirname): setup( name='hug', - version='2.4.2', + version='2.4.3', description='A Python framework that makes developing APIs ' 'as simple as possible, but no simpler.', long_description=long_description, diff --git a/tests/test_decorators.py b/tests/test_decorators.py index 0c94a089..dae2f6f0 100644 --- a/tests/test_decorators.py +++ b/tests/test_decorators.py @@ -662,7 +662,7 @@ def my_method(): def test_input_format(): """Test to ensure it's possible to quickly change the default hug output format""" old_format = api.http.input_format('application/json') - api.http.set_input_format('application/json', lambda a: {'no': 'relation'}) + api.http.set_input_format('application/json', lambda a, **headers: {'no': 'relation'}) @hug.get() def hello(body): @@ -682,7 +682,7 @@ def hello2(body): @pytest.mark.skipif(sys.platform == 'win32', reason='Currently failing on Windows build') def test_specific_input_format(): """Test to ensure the input formatter can be specified""" - @hug.get(inputs={'application/json': lambda a: 'formatted'}) + @hug.get(inputs={'application/json': lambda a, **headers: 'formatted'}) def hello(body): return body