Skip to content

Commit

Permalink
[fc] Repository: Products.Archetypes
Browse files Browse the repository at this point in the history
Branch: refs/heads/1.10.x
Date: 2017-05-30T11:26:18+02:00
Author: Godefroid Chapelle (gotcha) <[email protected]>
Commit: plone/Products.Archetypes@8f19e51

pin versions

Files changed:
M .travis.yml
Repository: Products.Archetypes
Branch: refs/heads/1.10.x
Date: 2017-05-30T13:00:04+02:00
Author: Godefroid Chapelle (gotcha) <[email protected]>
Commit: plone/Products.Archetypes@c25c057

Merge pull request #90 from plone/1.10.x-test-travis

test travis on branch 1.10.x

Files changed:
M .travis.yml
  • Loading branch information
gotcha committed May 30, 2017
1 parent 9bcbcd4 commit 1c6617e
Showing 1 changed file with 42 additions and 158 deletions.
200 changes: 42 additions & 158 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,174 +1,58 @@
Repository: plone.app.blob
Repository: Products.Archetypes


Branch: refs/heads/master
Date: 2017-05-23T09:53:56+02:00
Author: Bert Vanderbauwhede (batlock666) <[email protected]>
Commit: https://github.com/plone/plone.app.blob/commit/56ab7b221ff70ca6b5728706be0c1c3c9e68c868
Branch: refs/heads/1.10.x
Date: 2017-05-30T11:26:18+02:00
Author: Godefroid Chapelle (gotcha) <[email protected]>
Commit: https://github.com/plone/Products.Archetypes/commit/8f19e51bffeb240bd9c14cf1e4f4d177e41ed290

Handle ValueError exceptions when doing a range request.
pin versions

Files changed:
M CHANGES.rst
M src/plone/app/blob/download.py
M src/plone/app/blob/tests/test_integration.py
M .travis.yml

diff --git a/CHANGES.rst b/CHANGES.rst
index 6fa0223..235e2f4 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -14,7 +14,9 @@ New features:

Bug fixes:

-- *add item here*
+- Handle ``ValueError`` exceptions when doing a range request.
+ This fixes `issue #39 <https://github.com/plone/plone.app.blob/issues/39>`_.
+ [batlock666]


1.7.1 (2017-05-16)
diff --git a/src/plone/app/blob/download.py b/src/plone/app/blob/download.py
index 808bece..0151e20 100644
--- a/src/plone/app/blob/download.py
+++ b/src/plone/app/blob/download.py
@@ -73,12 +73,15 @@ def handleRequestRange(instance, length, REQUEST, RESPONSE):
ranges = None
RESPONSE.setHeader('Accept-Ranges', 'bytes')
if ranges and len(ranges) == 1:
- [(start, end)] = expandRanges(ranges, length)
- size = end - start
- RESPONSE.setHeader('Content-Length', size)
- RESPONSE.setHeader(
- 'Content-Range',
- 'bytes {0}-{1}/{2}'.format(start, end - 1, length))
- RESPONSE.setStatus(206) # Partial content
- return dict(start=start, end=end)
+ try:
+ [(start, end)] = expandRanges(ranges, length)
+ size = end - start
+ RESPONSE.setHeader('Content-Length', size)
+ RESPONSE.setHeader(
+ 'Content-Range',
+ 'bytes {0}-{1}/{2}'.format(start, end - 1, length))
+ RESPONSE.setStatus(206) # Partial content
+ return dict(start=start, end=end)
+ except ValueError:
+ return {}
return {}
diff --git a/src/plone/app/blob/tests/test_integration.py b/src/plone/app/blob/tests/test_integration.py
index 57bd15a..2dca3dd 100644
--- a/src/plone/app/blob/tests/test_integration.py
+++ b/src/plone/app/blob/tests/test_integration.py
@@ -153,6 +153,21 @@ def testRangeSupport(self):
iterator = blob.download(request)
self.assertEqual(data[-20:], ''.join(iterator))

+ def testOutsideRange(self):
+ # ranges outside the file size also have to work
+ blob = self.folder['blob']
+ blob.setTitle('foo')
+ blob.setFile(getData('plone.pdf'))
+ data = blob.getFile().getBlob().open('r').read()
+ l = len(data)
+ request = self.folder.REQUEST
+ request.environ['HTTP_RANGE'] = 'bytes={}-{}'.format(l * 2, l * 3)
+ iterator = blob.download(request)
+ self.assertEqual(data, ''.join(iterator))
+ request.environ['HTTP_RANGE'] = 'bytes={}-'.format(l * 2)
+ iterator = blob.download(request)
+ self.assertEqual(data, ''.join(iterator))
+
def testIcon(self):
blob = self.folder.blob
blob.update(file=getImage())
diff --git a/.travis.yml b/.travis.yml
index 39f5d774..acdc5791 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ cache:
before_install:
- mkdir -p $HOME/buildout-cache/{eggs,downloads}
- virtualenv .
- - bin/python bootstrap.py
+ - bin/python bootstrap.py --setuptools-version=26.1.1 --buildout-version=2.5.3 #from http://dist.plone.org/release/5-latest/versions.cfg 2017-05-30 11:25
install:
- bin/buildout -Nvt 5 -c travis.cfg
script:


Repository: plone.app.blob
Repository: Products.Archetypes


Branch: refs/heads/master
Date: 2017-05-29T10:05:04+02:00
Author: Gil Forcada Codinachs (gforcada) <[email protected]>
Commit: https://github.com/plone/plone.app.blob/commit/e5ebaaa1c45dd70c4a206144c07bee6a71591a50
Branch: refs/heads/1.10.x
Date: 2017-05-30T13:00:04+02:00
Author: Godefroid Chapelle (gotcha) <[email protected]>
Commit: https://github.com/plone/Products.Archetypes/commit/c25c057c027db209825d69884c9b53abd421d18c

Merge pull request #41 from batlock666/master
Merge pull request #90 from plone/1.10.x-test-travis

Handle ValueError exceptions when doing a range request. (Fixes issue #39)
test travis on branch 1.10.x

Files changed:
M CHANGES.rst
M src/plone/app/blob/download.py
M src/plone/app/blob/tests/test_integration.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 6fa0223..235e2f4 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -14,7 +14,9 @@ New features:

Bug fixes:

-- *add item here*
+- Handle ``ValueError`` exceptions when doing a range request.
+ This fixes `issue #39 <https://github.com/plone/plone.app.blob/issues/39>`_.
+ [batlock666]


1.7.1 (2017-05-16)
diff --git a/src/plone/app/blob/download.py b/src/plone/app/blob/download.py
index 808bece..0151e20 100644
--- a/src/plone/app/blob/download.py
+++ b/src/plone/app/blob/download.py
@@ -73,12 +73,15 @@ def handleRequestRange(instance, length, REQUEST, RESPONSE):
ranges = None
RESPONSE.setHeader('Accept-Ranges', 'bytes')
if ranges and len(ranges) == 1:
- [(start, end)] = expandRanges(ranges, length)
- size = end - start
- RESPONSE.setHeader('Content-Length', size)
- RESPONSE.setHeader(
- 'Content-Range',
- 'bytes {0}-{1}/{2}'.format(start, end - 1, length))
- RESPONSE.setStatus(206) # Partial content
- return dict(start=start, end=end)
+ try:
+ [(start, end)] = expandRanges(ranges, length)
+ size = end - start
+ RESPONSE.setHeader('Content-Length', size)
+ RESPONSE.setHeader(
+ 'Content-Range',
+ 'bytes {0}-{1}/{2}'.format(start, end - 1, length))
+ RESPONSE.setStatus(206) # Partial content
+ return dict(start=start, end=end)
+ except ValueError:
+ return {}
return {}
diff --git a/src/plone/app/blob/tests/test_integration.py b/src/plone/app/blob/tests/test_integration.py
index 57bd15a..2dca3dd 100644
--- a/src/plone/app/blob/tests/test_integration.py
+++ b/src/plone/app/blob/tests/test_integration.py
@@ -153,6 +153,21 @@ def testRangeSupport(self):
iterator = blob.download(request)
self.assertEqual(data[-20:], ''.join(iterator))

+ def testOutsideRange(self):
+ # ranges outside the file size also have to work
+ blob = self.folder['blob']
+ blob.setTitle('foo')
+ blob.setFile(getData('plone.pdf'))
+ data = blob.getFile().getBlob().open('r').read()
+ l = len(data)
+ request = self.folder.REQUEST
+ request.environ['HTTP_RANGE'] = 'bytes={}-{}'.format(l * 2, l * 3)
+ iterator = blob.download(request)
+ self.assertEqual(data, ''.join(iterator))
+ request.environ['HTTP_RANGE'] = 'bytes={}-'.format(l * 2)
+ iterator = blob.download(request)
+ self.assertEqual(data, ''.join(iterator))
+
def testIcon(self):
blob = self.folder.blob
blob.update(file=getImage())
M .travis.yml

diff --git a/.travis.yml b/.travis.yml
index 39f5d774..acdc5791 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ cache:
before_install:
- mkdir -p $HOME/buildout-cache/{eggs,downloads}
- virtualenv .
- - bin/python bootstrap.py
+ - bin/python bootstrap.py --setuptools-version=26.1.1 --buildout-version=2.5.3 #from http://dist.plone.org/release/5-latest/versions.cfg 2017-05-30 11:25
install:
- bin/buildout -Nvt 5 -c travis.cfg
script:


0 comments on commit 1c6617e

Please sign in to comment.