app: Return an empty string for HEAD requests
Some WSGI servers, e.g. Werkzeug, unconditionally attempt to iterate over the application response, even for HEAD requests. If `None` is returned, then the server will crash in this case, because it is not iterable. This commit alters the behavior of `milla.Application` to return an empty string, which is iterable and has the same effect of not sending a body.master
parent
c69dbed7ee
commit
e6774204a6
|
@ -1,4 +1,4 @@
|
||||||
# Copyright 2011 Dustin C. Hatch
|
# Copyright 2011, 2012, 2014, 2015 Dustin C. Hatch
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -112,7 +112,9 @@ class Application(object):
|
||||||
|
|
||||||
if not start_response_wrapper.called:
|
if not start_response_wrapper.called:
|
||||||
start_response(response.status, response.headerlist)
|
start_response(response.status, response.headerlist)
|
||||||
if not environ['REQUEST_METHOD'] == 'HEAD':
|
if environ['REQUEST_METHOD'] == 'HEAD':
|
||||||
|
return ''
|
||||||
|
else:
|
||||||
return response.app_iter
|
return response.app_iter
|
||||||
|
|
||||||
def _call_after(self, func):
|
def _call_after(self, func):
|
||||||
|
|
Loading…
Reference in New Issue