diff --git a/gunicorn/config.py b/gunicorn/config.py index 64c12d0777..7bdd508aef 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -190,6 +190,11 @@ def env(self): return env + @property + def sendfile(self): + return self.settings['sendfile'].get() is not False + + class SettingMeta(type): def __new__(cls, name, bases, attrs): @@ -281,6 +286,9 @@ def __lt__(self, other): def validate_bool(val): + if val is None: + return + if isinstance(val, bool): return val if not isinstance(val, six.string_types): diff --git a/gunicorn/http/wsgi.py b/gunicorn/http/wsgi.py index c537166ea7..f76d722d3f 100644 --- a/gunicorn/http/wsgi.py +++ b/gunicorn/http/wsgi.py @@ -347,7 +347,7 @@ def write(self, arg): util.write(self.sock, arg, self.chunked) def can_sendfile(self): - return self.cfg.sendfile is not False and sendfile is not None + return self.cfg.sendfile and sendfile is not None def sendfile(self, respiter): if self.cfg.is_ssl or not self.can_sendfile():