@send_async.register(asyncio.AbstractEventLoop)<EOL>async def _asyncio_send(loop, req, *, timeout=<NUM_LIT:10>, max_redirects=<NUM_LIT:10>):
if not any(h.lower() == '<STR_LIT>' for h in req.headers):<EOL><INDENT>req = req.with_headers({'<STR_LIT>': _ASYNCIO_USER_AGENT})<EOL><DEDENT>url = urllib.parse.urlsplit(<EOL>req.url + '<STR_LIT:?>' + urllib.parse.urlencode(req.params))<EOL>open_ = partial(asyncio.open_connection, url.hostname, loop=loop)<EOL>connect = open_(<NUM_LIT>, ssl=True) if url.scheme == '<STR_LIT>' else open_(<NUM_LIT>)<EOL>reader, writer = await connect<EOL>try:<EOL><INDENT>headers = '<STR_LIT:\r\n>'.join([<EOL>'<STR_LIT>'.format(req.method, url.path + '<STR_LIT:?>' + url.query),<EOL>'<STR_LIT>' + url.hostname,<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'.format(len(req.content or b'<STR_LIT>')),<EOL>'<STR_LIT:\r\n>'.join(starmap('<STR_LIT>'.format, req.headers.items())),<EOL>])<EOL>writer.write(b'<STR_LIT:\r\n>'.join([headers.encode('<STR_LIT>'),<EOL>b'<STR_LIT>', req.content or b'<STR_LIT>']))<EOL>response_bytes = BytesIO(<EOL>await asyncio.wait_for(reader.read(), timeout=timeout))<EOL><DEDENT>finally:<EOL><INDENT>writer.close()<EOL><DEDENT>resp = HTTPResponse(_SocketAdaptor(response_bytes),<EOL>method=req.method, url=req.url)<EOL>resp.begin()<EOL>status = resp.getcode()<EOL>if <NUM_LIT> <= status < <NUM_LIT> and '<STR_LIT>' in resp.headers and max_redirects:<EOL><INDENT>new_url = urllib.parse.urljoin(req.url, resp.headers['<STR_LIT>'])<EOL>return await _asyncio_send(<EOL>loop, req.replace(url=new_url),<EOL>timeout=timeout,<EOL>max_redirects=max_redirects-<NUM_LIT:1>)<EOL><DEDENT>return Response(status, content=resp.read(), headers=resp.headers)<EOL>
A rudimentary HTTP client using :mod:`asyncio`