mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Merge pull request #1175 from benoitc/fix/1174
reuse util.is_fileobject
This commit is contained in:
commit
305f373dc6
@ -353,9 +353,7 @@ class Response(object):
|
|||||||
if self.cfg.is_ssl or not self.can_sendfile():
|
if self.cfg.is_ssl or not self.can_sendfile():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
if not util.has_fileno(respiter.filelike):
|
||||||
fileno = respiter.filelike.fileno()
|
|
||||||
except AttributeError:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -510,14 +510,14 @@ def to_bytestring(value, encoding="utf8"):
|
|||||||
|
|
||||||
return value.encode(encoding)
|
return value.encode(encoding)
|
||||||
|
|
||||||
def is_fileobject(obj):
|
def has_fileno(obj):
|
||||||
if not hasattr(obj, "tell") or not hasattr(obj, "fileno"):
|
if not hasattr(obj, "fileno"):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# check BytesIO case and maybe others
|
# check BytesIO case and maybe others
|
||||||
try:
|
try:
|
||||||
obj.fileno()
|
obj.fileno()
|
||||||
except (IOError, io.UnsupportedOperation):
|
except (AttributeError, IOError, io.UnsupportedOperation):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user