From d4c772566be2c6a4909dee0161b9af607ebfbd1c Mon Sep 17 00:00:00 2001 From: Tom Most Date: Thu, 1 Dec 2016 21:48:06 -0800 Subject: [PATCH] Document request(unbuffered=True), add to example Fixes #116. --- docs/examples/download_file.py | 2 +- treq/api.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/examples/download_file.py b/docs/examples/download_file.py index 4a11074c..65da8434 100644 --- a/docs/examples/download_file.py +++ b/docs/examples/download_file.py @@ -5,7 +5,7 @@ def download_file(reactor, url, destination_filename): destination = open(destination_filename, 'wb') - d = treq.get(url) + d = treq.get(url, unbuffered=True) d.addCallback(treq.collect, destination.write) d.addBoth(lambda _: destination.close()) return d diff --git a/treq/api.py b/treq/api.py index 5262e6d3..0939cdc1 100644 --- a/treq/api.py +++ b/treq/api.py @@ -101,6 +101,9 @@ def request(method, url, **kwargs): (i.e. Ignore RFC2616 section 10.3 and follow redirects from POST requests). Default: ``False`` + :param bool unbuffered: Pass ``True`` to to disable response buffering. By + default treq buffers the entire response body in memory. + :rtype: Deferred that fires with an IResponse provider. """