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

Unified Diff: mojo/devtools/common/devtoolslib/http_server.py

Issue 1263093004: Do not use the gzipped file to compute the ETag. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 4 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/devtoolslib/http_server.py
diff --git a/mojo/devtools/common/devtoolslib/http_server.py b/mojo/devtools/common/devtoolslib/http_server.py
index 5199f3ee116bb1b6eb051371700f3e2a07a3d6fa..67bb4029bd57632194cfef0f7924fe0a70da32a2 100644
--- a/mojo/devtools/common/devtoolslib/http_server.py
+++ b/mojo/devtools/common/devtoolslib/http_server.py
@@ -74,7 +74,7 @@ def _GetHandlerClassForPath(mappings):
if self.etag:
return self.etag
- path = self.translate_path(self.path)
+ path = self.translate_path(self.path, False)
if not os.path.isfile(path):
return None
@@ -130,7 +130,8 @@ def _GetHandlerClassForPath(mappings):
return SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)
- def translate_path(self, path):
+ # pylint: disable=W0221
+ def translate_path(self, path, gzipped=True):
# Parent translate_path() will strip away the query string and fragment
# identifier, but also will prepend the cwd to the path. relpath() gives
# us the relative path back.
@@ -141,13 +142,14 @@ def _GetHandlerClassForPath(mappings):
if normalized_path.startswith(prefix):
result = os.path.join(local_base_path, normalized_path[len(prefix):])
if os.path.isfile(result):
- gz_result = result + '.gz'
- if (not os.path.isfile(gz_result) or
- os.path.getmtime(gz_result) <= os.path.getmtime(result)):
- with open(result, 'rb') as f:
- with gzip.open(gz_result, 'wb') as zf:
- shutil.copyfileobj(f, zf)
- result = gz_result
+ if gzipped:
+ gz_result = result + '.gz'
+ if (not os.path.isfile(gz_result) or
+ os.path.getmtime(gz_result) <= os.path.getmtime(result)):
+ with open(result, 'rb') as f:
+ with gzip.open(gz_result, 'wb') as zf:
+ shutil.copyfileobj(f, zf)
+ result = gz_result
return result
# This class is only used internally, and we're adding a catch-all ''
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698