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

Side by Side Diff: net/tools/backoff_server/backoff_server.py

Issue 6711046: Add an opt-out header for HTTP throttling. Never throttle for localhost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update copyright years. Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/python2.4
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """This is a simple HTTP server for manually testing exponential
7 back-off functionality in Chrome.
8 """
9
10
11 import BaseHTTPServer
12 import sys
13 import urlparse
14
15
16 class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
17 keep_running = True
18
19 def do_GET(self):
20 if self.path == '/quitquitquit':
21 self.send_response(200)
22 self.send_header('Content-Type', 'text/plain')
23 self.end_headers()
24 self.wfile.write('QUITTING')
25 RequestHandler.keep_running = False
26 return
27
28 params = urlparse.parse_qs(urlparse.urlparse(self.path).query)
29
30 if not params or not 'code' in params or params['code'][0] == '200':
31 self.send_response(200)
32 self.send_header('Content-Type', 'text/plain')
33 self.end_headers()
34 self.wfile.write('OK')
35 else:
36 self.send_error(int(params['code'][0]))
37
38
39 def main():
40 httpd = BaseHTTPServer.HTTPServer(('', int(sys.argv[1])), RequestHandler)
yzshen1 2011/03/18 22:49:51 It is good if some more comments are added for thi
Jói 2011/03/23 23:38:24 Done.
41 while RequestHandler.keep_running:
42 httpd.handle_request()
43
44
45 if __name__ == '__main__':
46 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698