Introducing a new way to review your PRs.

Read the announcement

aio-libs / aiohttp

Asynchronous HTTP client/server framework for asyncio and Python

View on GitHub

19 documents · Updated Nov 23, 2026

overview

Knowledge Base updated: 2026-11-22

aiohttp knowledge base

Orientation

aiohttp is an asyncio-based HTTP client and web-server framework. Its main implementation lives in aiohttp/, with distinct client, web-server, protocol/streaming, WebSocket, payload, and test-support layers.

Client request state is coordinated by ClientSession, connectors, cookie jars, and response objects. Server state is coordinated by Application, routers, request handlers, runners, and sites. Shared transport state lives in protocols, streams, parsers, writers, and WebSocket reader/writer machinery.

flowchart TD
    App[Application code]
    Client[ClientSession]
    Connector[TCPConnector]
    ClientReq[ClientRequest / ClientResponse]
    Cookie[CookieJar]
    Server[web.Application]
    Router[UrlDispatcher]
    Handler[Request handler]
    Runner[AppRunner / Site]
    Protocol[HTTP protocol]
    Streams[StreamReader / DataQueue]
    Parser[HTTP parser / writer]
    WS[WebSocket engine]
    Transport[asyncio transport]

    App --> Client
    Client --> Connector
    Client --> ClientReq
    Client --> Cookie
    Connector --> Protocol
    Server --> Router
    Router --> Handler
    Runner --> Server
    Protocol --> Streams
    Protocol --> Parser
    Parser --> Transport
    ClientReq --> WS
    Handler --> WS
    WS --> Transport

Glossary

  • ClientSession — client-side owner of request defaults, connector use, cookies, middleware, and tracing.
  • Connector — pool and lifecycle manager for outbound transports, DNS resolution, TLS, and proxy connections.
  • Application — web-server container for routes, middleware, signals, and lifecycle state.
  • Runner/Site — deployment-layer objects that bind an application to listening sockets and manage shutdown.
  • Payload — adapter that serializes application values into HTTP request or response body bytes.

Routing table