def main(): print('List of tuples') resp = yield from aiorequests.get('http://httpbin.org/get', params=[('foo', 'bar'), ('baz', 'bax')]) content = yield from resp.text() print(content) print('Single value dictionary') resp = yield from aiorequests.get('http://httpbin.org/get', params={'foo': 'bar', 'baz': 'bax'}) content = yield from resp.text() print(content) print('Multi value dictionary') resp = yield from aiorequests.get('http://httpbin.org/get', params={'foo': ['bar', 'baz', 'bax']}) content = yield from resp.text() print(content) print('Mixed value dictionary') resp = yield from aiorequests.get('http://httpbin.org/get', params={'foo': ['bar', 'baz'], 'bax': 'quux'}) content = yield from resp.text() print(content) print('Preserved query parameters') resp = yield from aiorequests.get('http://httpbin.org/get?foo=bar', params={'baz': 'bax'}) content = yield from resp.text() print(content)
def main(*args): r = yield from aiorequests.get('http://httpbin.org/get') print((yield from r.text()))
def download_file(*args): url, destination_filename = 'http://httpbin.org/get', 'download.txt' destination = open(destination_filename, 'wb') r = yield from aiorequests.get(url) destination.write((yield from r.text())) destination.close()
def main(*args): r = yield from aiorequests.get( 'http://httpbin.org/basic-auth/treq/treq', auth=('treq', 'treq') ) print((yield from r.text()))
def main(*args): resp = yield from aiorequests.get('http://httpbin.org/redirect/1') print(resp.original.status)
def main(*args): r = yield from aiorequests.get('http://httpbin.org/redirect/1', allow_redirects=False) print(r.original.status)