Skip to content

Instantly share code, notes, and snippets.

View pabloariasmora's full-sized avatar
🏠
Working from home

Juan Pablo Arias Mora pabloariasmora

🏠
Working from home
View GitHub Profile
@obskyr
obskyr / stream_response.py
Last active April 2, 2024 09:53
How to stream a requests response as a file-like object.
# -*- coding: utf-8 -*-
import requests
from io import BytesIO, SEEK_SET, SEEK_END
class ResponseStream(object):
def __init__(self, request_iterator):
self._bytes = BytesIO()
self._iterator = request_iterator