()
| 755 | |
| 756 | |
| 757 | def main() -> None: |
| 758 | from tornado.options import define, options, parse_command_line |
| 759 | |
| 760 | define("print_headers", type=bool, default=False) |
| 761 | define("print_body", type=bool, default=True) |
| 762 | define("follow_redirects", type=bool, default=True) |
| 763 | define("validate_cert", type=bool, default=True) |
| 764 | define("proxy_host", type=str) |
| 765 | define("proxy_port", type=int) |
| 766 | args = parse_command_line() |
| 767 | client = HTTPClient() |
| 768 | for arg in args: |
| 769 | try: |
| 770 | response = client.fetch( |
| 771 | arg, |
| 772 | follow_redirects=options.follow_redirects, |
| 773 | validate_cert=options.validate_cert, |
| 774 | proxy_host=options.proxy_host, |
| 775 | proxy_port=options.proxy_port, |
| 776 | ) |
| 777 | except HTTPError as e: |
| 778 | if e.response is not None: |
| 779 | response = e.response |
| 780 | else: |
| 781 | raise |
| 782 | if options.print_headers: |
| 783 | print(response.headers) |
| 784 | if options.print_body: |
| 785 | print(native_str(response.body)) |
| 786 | client.close() |
| 787 | |
| 788 | |
| 789 | if __name__ == "__main__": |
no test coverage detected