示例#1
0
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()
示例#2
0
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()
示例#3
0
文件: https.py 项目: smartree/monocle
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()
示例#4
0
def req():
    client = HttpClient()
    yield client.connect("localhost", 12344, timeout=1)
示例#5
0
def main():
    c = HttpClient()
    yield c.connect('google.com', 443, scheme='https')
    resp = yield c.request('/')
    print(resp.body)
    c.close()
示例#6
0
文件: tb.py 项目: ChrisWren/monocle
def req():
    client = HttpClient()
    yield client.connect("localhost", 12344, timeout=1)