From: Ben Darnell Date: Sat, 19 Feb 2011 23:31:11 +0000 (-0800) Subject: Add more debugging options to command-line mode of simple_httpclient X-Git-Tag: v1.2.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=907a9b461d2cecb51c482bef62f9466c24b01157;p=thirdparty%2Ftornado.git Add more debugging options to command-line mode of simple_httpclient --- diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index fbeb70862..2747f04ae 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -394,6 +394,9 @@ def match_hostname(cert, hostname): def main(): from tornado.options import define, options, parse_command_line + define("print_headers", type=bool, default=False) + define("print_body", type=bool, default=True) + define("follow_redirects", type=bool, default=True) args = parse_command_line() client = SimpleAsyncHTTPClient() io_loop = IOLoop.instance() @@ -401,8 +404,11 @@ def main(): def callback(response): io_loop.stop() response.rethrow() - print response.body - client.fetch(arg, callback) + if options.print_headers: + print response.headers + if options.print_body: + print response.body + client.fetch(arg, callback, follow_redirects=options.follow_redirects) io_loop.start() if __name__ == "__main__":