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

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

Issue 10873: Don't send Content-Type when redirecting from a POST.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2008 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 used for testing Chrome. 6 """This is a simple HTTP server used for testing Chrome.
7 7
8 It supports several test URLs, as specified by the handlers in TestPageHandler. 8 It supports several test URLs, as specified by the handlers in TestPageHandler.
9 It defaults to living on localhost:8888. 9 It defaults to living on localhost:8888.
10 It can use https if you specify the flag --https=CERT where CERT is the path 10 It can use https if you specify the flag --https=CERT where CERT is the path
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 self.CachePublicHandler, 81 self.CachePublicHandler,
82 self.CacheSMaxAgeHandler, 82 self.CacheSMaxAgeHandler,
83 self.CacheMustRevalidateHandler, 83 self.CacheMustRevalidateHandler,
84 self.CacheMustRevalidateMaxAgeHandler, 84 self.CacheMustRevalidateMaxAgeHandler,
85 self.CacheNoStoreHandler, 85 self.CacheNoStoreHandler,
86 self.CacheNoStoreMaxAgeHandler, 86 self.CacheNoStoreMaxAgeHandler,
87 self.CacheNoTransformHandler, 87 self.CacheNoTransformHandler,
88 self.DownloadHandler, 88 self.DownloadHandler,
89 self.DownloadFinishHandler, 89 self.DownloadFinishHandler,
90 self.EchoHeader, 90 self.EchoHeader,
91 self.EchoAllHandler,
91 self.FileHandler, 92 self.FileHandler,
92 self.RealFileWithCommonHeaderHandler, 93 self.RealFileWithCommonHeaderHandler,
93 self.RealBZ2FileWithCommonHeaderHandler, 94 self.RealBZ2FileWithCommonHeaderHandler,
94 self.AuthBasicHandler, 95 self.AuthBasicHandler,
95 self.AuthDigestHandler, 96 self.AuthDigestHandler,
96 self.SlowServerHandler, 97 self.SlowServerHandler,
97 self.ContentTypeHandler, 98 self.ContentTypeHandler,
98 self.ServerRedirectHandler, 99 self.ServerRedirectHandler,
99 self.ClientRedirectHandler, 100 self.ClientRedirectHandler,
100 self.DefaultResponseHandler] 101 self.DefaultResponseHandler]
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 413
413 self.send_response(200) 414 self.send_response(200)
414 self.send_header('Content-type', 'text/html') 415 self.send_header('Content-type', 'text/html')
415 self.end_headers() 416 self.end_headers()
416 self.wfile.write('<html><head><style>' 417 self.wfile.write('<html><head><style>'
417 'pre { border: 1px solid black; margin: 5px; padding: 5px }' 418 'pre { border: 1px solid black; margin: 5px; padding: 5px }'
418 '</style></head><body>' 419 '</style></head><body>'
419 '<div style="float: right">' 420 '<div style="float: right">'
420 '<a href="http://localhost:8888/echo">back to referring page</a></div>' 421 '<a href="http://localhost:8888/echo">back to referring page</a></div>'
421 '<h1>Request Body:</h1><pre>') 422 '<h1>Request Body:</h1><pre>')
422 length = int(self.headers.getheader('content-length'))
423 qs = self.rfile.read(length)
424 params = cgi.parse_qs(qs, keep_blank_values=1)
425 423
426 for param in params: 424 if self.command == 'POST':
427 self.wfile.write('%s=%s\n' % (param, params[param][0])) 425 length = int(self.headers.getheader('content-length'))
426 qs = self.rfile.read(length)
427 params = cgi.parse_qs(qs, keep_blank_values=1)
428
429 for param in params:
430 self.wfile.write('%s=%s\n' % (param, params[param][0]))
428 431
429 self.wfile.write('</pre>') 432 self.wfile.write('</pre>')
430 433
431 self.wfile.write('<h1>Request Headers:</h1><pre>%s</pre>' % self.headers) 434 self.wfile.write('<h1>Request Headers:</h1><pre>%s</pre>' % self.headers)
432 435
433 self.wfile.write('</body></html>') 436 self.wfile.write('</body></html>')
434 return True 437 return True
435 438
436 def DownloadHandler(self): 439 def DownloadHandler(self):
437 """This handler sends a downloadable file with or without reporting 440 """This handler sends a downloadable file with or without reporting
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 option_parser.add_option('', '--data-dir', dest='data_dir', 913 option_parser.add_option('', '--data-dir', dest='data_dir',
911 help='Directory from which to read the files') 914 help='Directory from which to read the files')
912 option_parser.add_option('', '--https', dest='cert', 915 option_parser.add_option('', '--https', dest='cert',
913 help='Specify that https should be used, specify ' 916 help='Specify that https should be used, specify '
914 'the path to the cert containing the private key ' 917 'the path to the cert containing the private key '
915 'the server should use') 918 'the server should use')
916 options, args = option_parser.parse_args() 919 options, args = option_parser.parse_args()
917 920
918 sys.exit(main(options, args)) 921 sys.exit(main(options, args))
919 922
OLDNEW
« no previous file with comments | « net/data/url_request_unittest/redirect-to-echoall.mock-http-headers ('k') | net/url_request/url_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698