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

Side by Side Diff: mojo/devtools/common/devtoolslib/http_server.py

Issue 1353463002: Fix http server to not gzip files when etag matches. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import atexit 5 import atexit
6 import datetime 6 import datetime
7 import email.utils 7 import email.utils
8 import errno 8 import errno
9 import hashlib 9 import hashlib
10 import logging 10 import logging
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 self.etag = '"%s"' % sha256.hexdigest() 112 self.etag = '"%s"' % sha256.hexdigest()
113 return self.etag 113 return self.etag
114 114
115 def send_head(self): 115 def send_head(self):
116 # Always close the connection after each request, as the keep alive 116 # Always close the connection after each request, as the keep alive
117 # support from SimpleHTTPServer doesn't like when the client requests to 117 # support from SimpleHTTPServer doesn't like when the client requests to
118 # close the connection before downloading the full response content. 118 # close the connection before downloading the full response content.
119 # pylint: disable=W0201 119 # pylint: disable=W0201
120 self.close_connection = 1 120 self.close_connection = 1
121 121
122 path = self.translate_path(self.path) 122 path = self.translate_path(self.path, False)
123 if os.path.isfile(path): 123 if os.path.isfile(path):
124 # Handle If-None-Match 124 # Handle If-None-Match
125 etag = self.get_etag() 125 etag = self.get_etag()
126 if ('If-None-Match' in self.headers and 126 if ('If-None-Match' in self.headers and
127 etag == self.headers['If-None-Match']): 127 etag == self.headers['If-None-Match']):
128 self.send_response(304) 128 self.send_response(304)
129 return None 129 return None
130 130
131 # Handle If-Modified-Since 131 # Handle If-Modified-Since
132 if ('If-None-Match' not in self.headers and 132 if ('If-None-Match' not in self.headers and
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 except socket.error as v: 235 except socket.error as v:
236 error_code = v[0] 236 error_code = v[0]
237 print 'Failed to start http server for %s on port %d: %s.' % ( 237 print 'Failed to start http server for %s on port %d: %s.' % (
238 str(mappings), host_port, os.strerror(error_code)) 238 str(mappings), host_port, os.strerror(error_code))
239 if error_code == errno.EADDRINUSE: 239 if error_code == errno.EADDRINUSE:
240 print (' Run `fuser %d/tcp` to find out which process is using the port;' 240 print (' Run `fuser %d/tcp` to find out which process is using the port;'
241 % host_port) 241 % host_port)
242 print (' or `fuser -k %d/tcp` terminate it.' % host_port) 242 print (' or `fuser -k %d/tcp` terminate it.' % host_port)
243 print '---' 243 print '---'
244 raise 244 raise
OLDNEW
« 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