connection_made is an asyncio.Protocol callback that a transport invokes after the underlying socket connects successfully. It receives the transport, which the protocol can use to communicate with the server immediately. section 8.2
Use connection_made as the opening step in a transport-and-protocol exchange:
- Define a class extending asyncio.Protocol. section 8.2
- Accept the transport and write the HTTP request as soon as the connection is established. section 8.2
- Handle subsequent bytes in data_received and completion in eof_received. section 8.2
Starting an HTTP GET
HTTPGetClientProtocol.connection_made stores or uses the supplied transport to send a GET / HTTP/1.1 request. loop.create_connection constructs the protocol, while get_response awaits the eventual response.
