diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 23:47:50 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 23:47:50 +0000 |
commit | 043555fed6707e0524c01df5a54188ef7ff2a1f0 (patch) | |
tree | 60a9a9602903f21f7bb36303c55c112b49460139 /net/tools/testserver | |
parent | 131e02cf82eb6ec0b2e8f6bb1b0f2f149373b33d (diff) | |
download | chromium_src-043555fed6707e0524c01df5a54188ef7ff2a1f0.zip chromium_src-043555fed6707e0524c01df5a54188ef7ff2a1f0.tar.gz chromium_src-043555fed6707e0524c01df5a54188ef7ff2a1f0.tar.bz2 |
Add a PDF test to load all the pdfs in a test directory, using the test server. This tests regressions in loading and crashes.
Review URL: http://codereview.chromium.org/5141001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools/testserver')
-rwxr-xr-x | net/tools/testserver/testserver.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py index 2a13c2b..2551139 100755 --- a/net/tools/testserver/testserver.py +++ b/net/tools/testserver/testserver.py @@ -221,7 +221,8 @@ class TestPageHandler(BasePageHandler): 'gif': 'image/gif', 'jpeg' : 'image/jpeg', 'jpg' : 'image/jpeg', - 'xml' : 'text/xml' + 'xml' : 'text/xml', + 'pdf' : 'application/pdf' } self._default_mime_type = 'text/html' @@ -698,9 +699,27 @@ class TestPageHandler(BasePageHandler): else: # Could be more generic once we support mime-type sniffing, but for # now we need to set it explicitly. - self.send_response(200) + + range = self.headers.get('Range') + if range and range.startswith('bytes='): + # Note this doesn't handle all valid byte range values (i.e. open ended + # ones), just enough for what we needed so far. + range = range[6:].split('-') + start = int(range[0]) + end = int(range[1]) + + self.send_response(206) + content_range = 'bytes ' + str(start) + '-' + str(end) + '/' + \ + str(len(data)) + self.send_header('Content-Range', content_range) + data = data[start: end + 1] + else: + self.send_response(200) + self.send_header('Content-type', self.GetMIMETypeFromName(file_path)) + self.send_header('Accept-Ranges', 'bytes') self.send_header('Content-Length', len(data)) + self.send_header('ETag', '\'' + file_path + '\'') self.end_headers() self.wfile.write(data) |