def req(): client = HttpClient() try: yield client.connect("www.google.com", 80) resp = yield client.request('/') print resp.code, repr(resp.body) resp = yield client.request('http://www.google.com/') print resp.code, repr(resp.body) client.close() yield client.connect("localhost", 80) resp = yield client.request('/') print resp.code, repr(resp.body) resp = yield client.request('http://localhost/') print resp.code, repr(resp.body) finally: eventloop.halt()
def example(): client = HttpClient() yield client.connect("www.google.com", 443, "https") print("connected") resp = yield client.request('/') print("response code -> %s" % resp.code) print("page length -> %s" % len(repr(resp.body))) client.close()
def req(): client = HttpClient() yield client.connect("localhost", 12344, timeout=1)
def main(): c = HttpClient() yield c.connect('google.com', 443, scheme='https') resp = yield c.request('/') print(resp.body) c.close()