Chromium Code Reviews| 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 d8a275770135205263026d3cba56a3aa733ddf77..6267af9531d1a062fee5eb75bb7555bc7dedce11 100644 | 
| --- a/mojo/devtools/common/devtoolslib/http_server.py | 
| +++ b/mojo/devtools/common/devtoolslib/http_server.py | 
| @@ -6,15 +6,14 @@ import atexit | 
| import datetime | 
| import email.utils | 
| import errno | 
| -import gzip | 
| import hashlib | 
| import logging | 
| import math | 
| import os.path | 
| -import shutil | 
| import socket | 
| -import threading | 
| +import subprocess | 
| import tempfile | 
| +import threading | 
| import SimpleHTTPServer | 
| import SocketServer | 
| @@ -146,24 +145,30 @@ def _get_handler_class_for_path(mappings): | 
| SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self, path)) | 
| for prefix, local_base_path_list in mappings: | 
| - if normalized_path.startswith(prefix): | 
| - for local_base_path in local_base_path_list: | 
| - candidate = os.path.join(local_base_path, | 
| - normalized_path[len(prefix):]) | 
| - if os.path.isfile(candidate): | 
| - 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) | 
| - self.gzipped_file.close() | 
| - return self.gzipped_file.name | 
| - return candidate | 
| - else: | 
| - self.send_response(404) | 
| - return None | 
| + if not normalized_path.startswith(prefix): | 
| + continue | 
| + | 
| + for local_base_path in local_base_path_list: | 
| + candidate = os.path.join(local_base_path, | 
| + normalized_path[len(prefix):]) | 
| + if os.path.isfile(candidate): | 
| + if gzipped: | 
| + if not self.gzipped_file: | 
| + self.gzipped_file = tempfile.NamedTemporaryFile(delete=False) | 
| 
 
piotrt
2015/08/25 11:55:23
I would consider extracting lines 157-166? to a se
 
ppi
2015/08/25 12:07:43
Good point, done.
 
 | 
| + self.original_file_name = candidate | 
| + try: | 
| + subprocess.check_call(['gzip', '-c', candidate], | 
| + stdout=self.gzipped_file) | 
| + except Exception: | 
| + print ('http_server: call to gzip failed, make sure that ' | 
| + 'gzip is installed on the host.') | 
| + raise | 
| + self.gzipped_file.close() | 
| + return self.gzipped_file.name | 
| + return candidate | 
| + else: | 
| + self.send_response(404) | 
| + return None | 
| self.send_response(404) | 
| return None |