Skip to content

Commit

Permalink
Rebase on master, add another test. Confused as to what's going on
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcgibbo committed Nov 26, 2015
1 parent 7a21a86 commit 1dd1e51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cachecontrol/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ def build_response(self, request, response, from_cache=False):
)
)
if response.chunked:
super_update_chunk_length = response._update_chunk_length

original_update_chunk_length = response._update_chunk_length
def _update_chunk_length(self):
super_update_chunk_length()
original_update_chunk_length()
if self.chunk_left == 0:
self._fp._close()
response._update_chunk_length = types.MethodType(_update_chunk_length, response)


resp = super(CacheControlAdapter, self).build_response(
request, response
)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
from cachecontrol import CacheControl


class TestNonchunked(object):
def test_not_cached_when_content_is_not_read(self, url):
sess = CacheControl(requests.Session())
sess.get(url)
resp = sess.get(url)

assert not resp.from_cache


class TestStream(object):
def test_stream_is_cached(self, url):
sess = CacheControl(requests.Session())
Expand Down

0 comments on commit 1dd1e51

Please sign in to comment.