| 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 ec6973de70212a521ef54035abe4fb5c3214624a..c01928ace29b64d1e459f88ae8697e040ec4f8e1 100644
|
| --- a/mojo/devtools/common/devtoolslib/http_server.py
|
| +++ b/mojo/devtools/common/devtoolslib/http_server.py
|
| @@ -6,10 +6,12 @@ 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
|
|
|
| @@ -120,6 +122,7 @@ def _GetHandlerClassForPath(mappings):
|
| path = self.translate_path(self.path)
|
|
|
| if os.path.isfile(path):
|
| + self.send_header('Content-Encoding', 'gzip')
|
| etag = self.get_etag()
|
| if etag:
|
| self.send_header('ETag', etag)
|
| @@ -136,7 +139,16 @@ def _GetHandlerClassForPath(mappings):
|
|
|
| for prefix, local_base_path in mappings:
|
| if normalized_path.startswith(prefix):
|
| - return os.path.join(local_base_path, normalized_path[len(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
|
| + return result
|
|
|
| # This class is only used internally, and we're adding a catch-all ''
|
| # prefix at the end of |mappings|.
|
|
|