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

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

Issue 1278153002: Devtools: fix MIME type inferrence. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address Ben's comments. 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 | mojo/devtools/common/devtoolslib/http_server_unittest.py » ('j') | 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 482e2db53108fe8aa120ba37e650543ce7c9d81c..16c76a98d5189638e0dfcb3a8d454ac21a6fc691 100644
--- a/mojo/devtools/common/devtoolslib/http_server.py
+++ b/mojo/devtools/common/devtoolslib/http_server.py
@@ -74,6 +74,7 @@ def _get_handler_class_for_path(mappings):
def __init__(self, *args, **kwargs):
self.etag = None
self.gzipped_file = None
+ self.original_file_name = None
SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(self, *args, **kwargs)
def get_etag(self):
@@ -153,6 +154,7 @@ def _get_handler_class_for_path(mappings):
if gzipped:
if not self.gzipped_file:
self.gzipped_file = tempfile.NamedTemporaryFile(delete=False)
+ self.original_file_name = candidate
with open(candidate, 'rb') as source:
with gzip.GzipFile(fileobj=self.gzipped_file) as target:
shutil.copyfileobj(source, target)
@@ -170,9 +172,12 @@ def _get_handler_class_for_path(mappings):
# thanks to content-type mappings.
# TODO(ppi): drop this part once we can rely on the Sky files declaring
# correct shebang.
- if path.endswith('.dart') or path.endswith('.dart.gz'):
+ actual_path = self.original_file_name or path
+
+ if actual_path.endswith('.dart'):
return 'application/dart'
- return SimpleHTTPServer.SimpleHTTPRequestHandler.guess_type(self, path)
+ return SimpleHTTPServer.SimpleHTTPRequestHandler.guess_type(self,
+ actual_path)
def log_message(self, *_):
"""Override the base class method to disable logging."""
« no previous file with comments | « no previous file | mojo/devtools/common/devtoolslib/http_server_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698