aboutsummaryrefslogtreecommitdiff
path: root/urllib3/util/response.py
diff options
context:
space:
mode:
Diffstat (limited to 'urllib3/util/response.py')
-rw-r--r--urllib3/util/response.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/urllib3/util/response.py b/urllib3/util/response.py
new file mode 100644
index 0000000..d0325bc
--- /dev/null
+++ b/urllib3/util/response.py
@@ -0,0 +1,13 @@
+def is_fp_closed(obj):
+ """
+ Checks whether a given file-like object is closed.
+
+ :param obj:
+ The file-like object to check.
+ """
+ if hasattr(obj, 'fp'):
+ # Object is a container for another file-like object that gets released
+ # on exhaustion (e.g. HTTPResponse)
+ return obj.fp is None
+
+ return obj.closed