From 5fb6e3952c67fb9c36c920613e3adaf43d4510e7 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 26 Jun 2011 14:03:51 -0700 Subject: [PATCH] Consolidate httpclient main() functions --- tornado/curl_httpclient.py | 1 + tornado/simple_httpclient.py | 22 ++-------------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index 8b4e97e80..7e8d78f2e 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -429,4 +429,5 @@ def _curl_debug(debug_type, debug_msg): logging.debug('%s %r', debug_types[debug_type], debug_msg) if __name__ == "__main__": + AsyncHTTPClient.configure(CurlAsyncHTTPClient) main() diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index 5d0886790..d592c580d 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -2,7 +2,7 @@ from __future__ import with_statement from tornado.escape import utf8, _unicode, native_str -from tornado.httpclient import HTTPRequest, HTTPResponse, HTTPError, AsyncHTTPClient +from tornado.httpclient import HTTPRequest, HTTPResponse, HTTPError, AsyncHTTPClient, main from tornado.httputil import HTTPHeaders from tornado.ioloop import IOLoop from tornado.iostream import IOStream, SSLIOStream @@ -418,24 +418,6 @@ def match_hostname(cert, hostname): raise CertificateError("no appropriate commonName or " "subjectAltName fields were found") -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() - 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__": + AsyncHTTPClient.configure(SimpleAsyncHTTPClient) main() -- 2.47.2