Skip to content

Instantly share code, notes, and snippets.

View GlitchedCode's full-sized avatar
🕹️
gaming time

Giuseppe La Malfa GlitchedCode

🕹️
gaming time
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