Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: net/tools/testserver/testserver.py

Issue 5141001: Add a PDF test to load all the pdfs in a test directory, using the test serve... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix race condition Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/plugin/pdf_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/testserver.py
===================================================================
--- net/tools/testserver/testserver.py (revision 66374)
+++ net/tools/testserver/testserver.py (working copy)
@@ -221,7 +221,8 @@
'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 @@
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)
« no previous file with comments | « chrome/test/plugin/pdf_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698