Merge branch 'develop'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parents 8c1fd5d, 0e711f2 · Browse files · 10 files·+76 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+76 added−15 removed
- other:+76 added−15 removed
Provenance
- Commit
19a2a6c- Tree
6fcd331- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent 1
8c1fd5d- Parent 2
0e711f2
10 files changed+76 added−15 removed
modified:docs/index.rst+2 added-2 removed
96 unmodified lines97 This part of the documentation, which is mostly prose, details the98 Requests ecosystem and community.99 100 .. toctree::101- :maxdepth: 2101+ :maxdepth: 1102 103 community/faq104 community/out-there.rst105 community/support17 unmodified lines123 If you want to contribute to the project, this part of the documentation is for124 you.125 126 .. toctree::127- :maxdepth: 2127+ :maxdepth: 1128 129 dev/internals130 dev/todo131 dev/authorsmodified:requests/__init__.py+2 added-2 removed
13 unmodified lines14 15 """16 17 __title__ = 'requests'18-__version__ = '0.8.4'19-__build__ = 0x00080418+__version__ = '0.8.5'19+__build__ = 0x00080520 __author__ = 'Kenneth Reitz'21 __license__ = 'ISC'22 __copyright__ = 'Copyright 2011 Kenneth Reitz'23 11 unmodified linesmodified:requests/api.py-1 removed
11 unmodified lines12 """13 14 from . import sessions15 16-16 def request(method, url,17 params=None,18 data=None,19 headers=None,125 unmodified linesmodified:requests/models.py+46 added
570 unmodified lines571 572 return gen573 574 575+ def iter_lines(self, newlines=None, decode_unicode=None):576+ """Iterates over the response data, one line at a time. This577+ avoids reading the content at once into memory for large578+ responses.579+580+ :param newlines: a collection of bytes to seperate lines with.581+ """582+583+ if newlines is None:584+ newlines = ('\r', '\n', '\r\n')585+586+ if self._content_consumed:587+ raise RuntimeError(588+ 'The content for this response was already consumed'589+ )590+591+ def generate():592+ chunk = []593+594+ while 1:595+ c = self.raw.read(1)596+ if not c:597+ break598+599+ if c in newlines:600+ yield ''.join(chunk)601+ chunk = []602+ else:603+ chunk.append(c)604+605+ self._content_consumed = True606+607+ gen = generate()608+609+ if 'gzip' in self.headers.get('content-encoding', ''):610+ gen = stream_decode_gzip(gen)611+612+ if decode_unicode is None:613+ decode_unicode = self.config.get('decode_unicode')614+615+ if decode_unicode:616+ gen = stream_decode_response_unicode(gen, self)617+618+ return gen619+620+621 @property622 def content(self):623 """Content of the response, in bytes or unicode624 (if available).59 unmodified linesmodified:HISTORY.rst+5 added
1 History2 -------3 4+0.8.5 (2011-12-14)5+++++++++++++++++++6+7+* Response.iter_lines!8+9 0.8.4 (2011-12-11)10 ++++++++++++++++++11 12 * Prefetch bugfix.275 unmodified linesmodified:Makefile+1 added-1 removed
1 init:2- pip install -r reqs.txt2+ pip install -r requirements.txt3 4 test:5 nosetests --with-color test_requests.py6 10 unmodified linesmodified:NOTICE-1 removed
21 unmodified lines22 PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE23 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR24 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER25 DEALINGS IN THE SOFTWARE.26-deleted:reqs.txt-7 removed
1-envoy==0.0.22-httpbin==0.0.43-gunicorn4-nose5-pyflakes6-omnijson7-rudolf2added:requirements.txt+7 added
1+envoy==0.0.22+httpbin==0.0.63+gunicorn4+nose5+pyflakes6+omnijson7+rudolf2modified:test_requests.py+13 added-1 removed
426 unmodified lines427 self.assertEquals(r.status_code, 200)428 self.assertEquals(r.headers['content-type'], 'application/json')429 self.assertEquals(r.url, service('post?test=foo&test=baz'))430 rbody = json.loads(r.content)431- self.assertEquals(rbody.get('form'), dict(test2='foobar',test3='foo'))431+ self.assertEquals(rbody.get('form'), dict(test2='foobar',test3=['foo','baz']))432 self.assertEquals(rbody.get('data'), '')433 434 435 def test_GET_no_redirect(self):152 unmodified lines588 assert r1.content589 assert r1.content590 591 r2 = requests.get(httpbin('get'), prefetch=True)592+ assert r2._content593 assert r2.content594 595+ def test_iter_lines(self):596+597+ lines = (0, 2, 10, 100)598+599+ for i in lines:600+601+ r = requests.get(httpbin('stream', str(i)), prefetch=False)602+ len_lines = len([l for l in r.iter_lines()])603+604+ self.assertEqual(i, len_lines)605+606 if __name__ == '__main__':607 unittest.main()