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

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

Issue 10190002: Remove X-Retry-After support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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
« no previous file with comments | « net/base/net_log_event_type_list.h ('k') | net/url_request/url_request_throttler_entry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """This is a simple HTTP server for manually testing exponential 6 """This is a simple HTTP server for manually testing exponential
7 back-off functionality in Chrome. 7 back-off functionality in Chrome.
8 """ 8 """
9 9
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 self.send_response(200) 71 self.send_response(200)
72 self.send_header('Content-Type', 'text/html') 72 self.send_header('Content-Type', 'text/html')
73 self.end_headers() 73 self.end_headers()
74 self.wfile.write(AJAX_TEST_PAGE % (self.local_ip, 74 self.wfile.write(AJAX_TEST_PAGE % (self.local_ip,
75 self.port, 75 self.port,
76 self.path[6:])) 76 self.path[6:]))
77 return 77 return
78 78
79 params = urlparse.parse_qs(urlparse.urlparse(self.path).query) 79 params = urlparse.parse_qs(urlparse.urlparse(self.path).query)
80 80
81 def SendCustomRetryIfRequested():
82 if params and 'custom-retry-after' in params:
83 custom_retry = params['custom-retry-after'][0]
84 self.send_header('X-Retry-After', custom_retry)
85
86 if not params or not 'code' in params or params['code'][0] == '200': 81 if not params or not 'code' in params or params['code'][0] == '200':
87 self.send_response(200) 82 self.send_response(200)
88 self.send_header('Content-Type', 'text/plain') 83 self.send_header('Content-Type', 'text/plain')
89 SendCustomRetryIfRequested()
90 self.end_headers() 84 self.end_headers()
91 self.wfile.write('OK') 85 self.wfile.write('OK')
92 else: 86 else:
93 status_code = int(params['code'][0]) 87 status_code = int(params['code'][0])
94 self.send_response(status_code) 88 self.send_response(status_code)
95 SendCustomRetryIfRequested()
96 self.end_headers() 89 self.end_headers()
97 self.wfile.write('Error %d' % int(status_code)) 90 self.wfile.write('Error %d' % int(status_code))
98 91
99 92
100 def main(): 93 def main():
101 if len(sys.argv) != 3: 94 if len(sys.argv) != 3:
102 print "Usage: %s LOCAL_IP PORT" % sys.argv[0] 95 print "Usage: %s LOCAL_IP PORT" % sys.argv[0]
103 sys.exit(1) 96 sys.exit(1)
104 RequestHandler.local_ip = sys.argv[1] 97 RequestHandler.local_ip = sys.argv[1]
105 port = int(sys.argv[2]) 98 port = int(sys.argv[2])
106 RequestHandler.port = port 99 RequestHandler.port = port
107 print "To stop the server, go to http://localhost:%d/quitquitquit" % port 100 print "To stop the server, go to http://localhost:%d/quitquitquit" % port
108 httpd = BaseHTTPServer.HTTPServer(('', port), RequestHandler) 101 httpd = BaseHTTPServer.HTTPServer(('', port), RequestHandler)
109 while RequestHandler.keep_running: 102 while RequestHandler.keep_running:
110 httpd.handle_request() 103 httpd.handle_request()
111 104
112 105
113 if __name__ == '__main__': 106 if __name__ == '__main__':
114 main() 107 main()
OLDNEW
« no previous file with comments | « net/base/net_log_event_type_list.h ('k') | net/url_request/url_request_throttler_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698