b2sdk.requests – modified requests.models.Response class

This file contains modified parts of the requests module (https://github.com/psf/requests, models.py), original Copyright 2019 Kenneth Reitz

Changes made to the original source: see NOTICE

class b2sdk.requests.NotDecompressingResponse[source]
iter_content(chunk_size=1, decode_unicode=False)[source]

Iterates over the response data. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is not necessarily the length of each item returned as decoding can take place.

chunk_size must be of type int or None. A value of None will function differently depending on the value of stream. stream=True will read data as it arrives in whatever size the chunks are received. If stream=False, data is returned as a single chunk.

If decode_unicode is True, content will be decoded using the best available encoding based on the response.

classmethod from_builtin_response(response: Response)[source]

Create a b2sdk.requests.NotDecompressingResponse object from a requests.Response object. Don’t use Response.__getstate__ and Response.__setstate__ because these assume that the content has been consumed, which will never be true in our case.