Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix #143: off-by-one range in iterator.KeyIterator.get_headers.#196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
silvolu
merged 2 commits into
googleapis:master
from
tseaver:143-storage.iterator.KeyDataIterator-off_by_one_chunkingSep 30, 2014
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -206,29 +206,29 @@ def test_ctor(self): | ||
| def test__iter__(self): | ||
| response1 = _Response(status=200) | ||
| response1['content-range'] = '0-10/15' | ||
| response1['content-range'] = '0-9/15' | ||
| response2 = _Response(status=200) | ||
| response2['content-range'] = '11-14/15' | ||
| connection = _Connection((response1, '01234567890'), | ||
| (response2, '1234'), | ||
| response2['content-range'] = '10-14/15' | ||
| connection = _Connection((response1, '0123456789'), | ||
| (response2, '01234'), | ||
| ) | ||
| key = _Key(connection) | ||
| iterator = self._makeOne(key) | ||
| chunks = list(iterator) | ||
| self.assertEqual(len(chunks), 2) | ||
| self.assertEqual(chunks[0], '01234567890') | ||
| self.assertEqual(chunks[1], '1234') | ||
| self.assertEqual(chunks[0], '0123456789') | ||
| self.assertEqual(chunks[1], '01234') | ||
| self.assertEqual(iterator._bytes_written, 15) | ||
| self.assertEqual(iterator._total_bytes, 15) | ||
| kws = connection._requested | ||
| self.assertEqual(kws[0]['method'], 'GET') | ||
| self.assertEqual(kws[0]['url'], | ||
| self.assertEqual(kws[0]['url'], | ||
| 'http://example.com/b/name/o/key?alt=media') | ||
| self.assertEqual(kws[0]['headers'], {'Range': 'bytes=0-10'}) | ||
| self.assertEqual(kws[0]['headers'], {'Range': 'bytes=0-9'}) | ||
| self.assertEqual(kws[1]['method'], 'GET') | ||
| self.assertEqual(kws[1]['url'], | ||
| self.assertEqual(kws[1]['url'], | ||
| 'http://example.com/b/name/o/key?alt=media') | ||
| self.assertEqual(kws[1]['headers'], {'Range': 'bytes=11-'}) | ||
| self.assertEqual(kws[1]['headers'], {'Range': 'bytes=10-'}) | ||
| def test_reset(self): | ||
| connection = _Connection() | ||
| @@ -275,7 +275,7 @@ def test_get_headers_new(self): | ||
| iterator = self._makeOne(key) | ||
| headers = iterator.get_headers() | ||
| self.assertEqual(len(headers), 1) | ||
| self.assertEqual(headers['Range'], 'bytes=0-10') | ||
| self.assertEqual(headers['Range'], 'bytes=0-9') | ||
| def test_get_headers_ok(self): | ||
| connection = _Connection() | ||
| @@ -285,7 +285,7 @@ def test_get_headers_ok(self): | ||
| iterator._total_bytes = 1000 | ||
| headers = iterator.get_headers() | ||
| self.assertEqual(len(headers), 1) | ||
| self.assertEqual(headers['Range'], 'bytes=10-20') | ||
| self.assertEqual(headers['Range'], 'bytes=10-19') | ||
| def test_get_headers_off_end(self): | ||
| connection = _Connection() | ||
| @@ -313,7 +313,7 @@ def test_get_next_chunk_underflow(self): | ||
| def test_get_next_chunk_200(self): | ||
| response = _Response(status=200) | ||
| response['content-range'] = '0-10/100' | ||
| response['content-range'] = '0-9/100' | ||
| connection = _Connection((response, 'CHUNK')) | ||
| key = _Key(connection) | ||
| iterator = self._makeOne(key) | ||
| @@ -323,9 +323,9 @@ def test_get_next_chunk_200(self): | ||
| self.assertEqual(iterator._total_bytes, 100) | ||
| kw, = connection._requested | ||
| self.assertEqual(kw['method'], 'GET') | ||
| self.assertEqual(kw['url'], | ||
| self.assertEqual(kw['url'], | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| 'http://example.com/b/name/o/key?alt=media') | ||
| self.assertEqual(kw['headers'], {'Range': 'bytes=0-10'}) | ||
| self.assertEqual(kw['headers'], {'Range': 'bytes=0-9'}) | ||
| def test_get_next_chunk_206(self): | ||
| response = _Response(status=206) | ||
| @@ -338,9 +338,9 @@ def test_get_next_chunk_206(self): | ||
| self.assertEqual(iterator._bytes_written, len(chunk)) | ||
| kw, = connection._requested | ||
| self.assertEqual(kw['method'], 'GET') | ||
| self.assertEqual(kw['url'], | ||
| self.assertEqual(kw['url'], | ||
| 'http://example.com/b/name/o/key?alt=media') | ||
| self.assertEqual(kw['headers'], {'Range': 'bytes=0-10'}) | ||
| self.assertEqual(kw['headers'], {'Range': 'bytes=0-9'}) | ||
| def test_get_next_chunk_416(self): | ||
| response = _Response(status=416) | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.