Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/timothycrosley/hug into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
timothycrosley committed Jan 31, 2018
2 parents 89372ab + 36e977a commit b9b7baf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hug/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def handle_404(request, response, *args, **kwargs):
prefix=url_prefix)
response.data = hug.output_format.json(to_return, indent=4, separators=(',', ': '))
response.status = falcon.HTTP_NOT_FOUND
response.content_type = 'application/json'
response.content_type = 'application/json; charset=utf-8'
handle_404.interface = True
return handle_404

Expand Down
10 changes: 5 additions & 5 deletions hug/output_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def numpy_floatable(item):
return float(item)


@content_type('application/json')
@content_type('application/json; charset=utf-8')
def json(content, request=None, response=None, ensure_ascii=False, **kwargs):
"""JSON (Javascript Serialized Object Notation)"""
if hasattr(content, 'read'):
Expand Down Expand Up @@ -141,7 +141,7 @@ def output_content(content, response, **kwargs):
return wrapper


@content_type('text/plain')
@content_type('text/plain; charset=utf-8')
def text(content, **kwargs):
"""Free form UTF-8 text"""
if hasattr(content, 'read'):
Expand All @@ -150,7 +150,7 @@ def text(content, **kwargs):
return str(content).encode('utf8')


@content_type('text/html')
@content_type('text/html; charset=utf-8')
def html(content, **kwargs):
"""HTML (Hypertext Markup Language)"""
if hasattr(content, 'read'):
Expand Down Expand Up @@ -178,13 +178,13 @@ def _camelcase(content):
return content


@content_type('application/json')
@content_type('application/json; charset=utf-8')
def json_camelcase(content, **kwargs):
"""JSON (Javascript Serialized Object Notation) with all keys camelCased"""
return json(_camelcase(content), **kwargs)


@content_type('application/json')
@content_type('application/json; charset=utf-8')
def pretty_json(content, **kwargs):
"""JSON (Javascript Serialized Object Notion) pretty printed and indented"""
return json(content, indent=4, separators=(',', ': '), **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion hug/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def call(method, api_or_module, url, body='', headers=None, params=None, query_s
except (UnicodeDecodeError, AttributeError):
response.data = result[0]
response.content_type = response.headers_dict['content-type']
if response.content_type == 'application/json':
if 'application/json' in response.content_type:
response.data = json.loads(response.data)

return response
Expand Down

0 comments on commit b9b7baf

Please sign in to comment.