Skip to content

Commit

Permalink
Add more debugging options to command-line mode of simple_httpclient
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Feb 19, 2011
1 parent 5f73de9 commit 907a9b4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tornado/simple_httpclient.py
Expand Up @@ -394,15 +394,21 @@ 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()
for arg in args:
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__":
Expand Down

0 comments on commit 907a9b4

Please sign in to comment.