Skip to content

Commit 3732ca5

Browse files
committed
requests: Add context manager for response object.
Signed-off-by: Phil Howard <github@gadgetoid.com>
1 parent 381ac74 commit 3732ca5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

python-ecosys/requests/requests/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ def json(self):
3232

3333
return json.loads(self.content)
3434

35+
def __enter__(self):
36+
return self
37+
38+
def __exit__(self, exc_type, exc_val, exc_tb):
39+
self.close()
40+
3541

3642
def request(
3743
method,

0 commit comments

Comments
 (0)