# dart-lang/http architecture

> Architecture diagram of the GitHub repository dart-lang/http, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dart-lang/http
- Repository: https://github.com/dart-lang/http

## Overview

This repository is a Dart networking-package monorepo. The principal workflow is an application using package:http to make a request and consume an HTTP resource; the README describes the API as composable and multi-platform. Other packages provide HTTP/2, HTTP parsing and server support, profiling, native client integrations, and WebSocket APIs. The sampled source is mostly platform-runner boilerplate, so internal calls and most package-to-package relationships are not established here; dashed links mark those unverified integrations.

Main entry points: [`pkgs/http/lib/http.dart`](https://github.com/dart-lang/http/blob/master/pkgs/http/lib/http.dart) (HTTP API), [`pkgs/http/lib/src/request.dart`](https://github.com/dart-lang/http/blob/master/pkgs/http/lib/src/request.dart) (Requests and responses), [`pkgs/http/lib/src/io_client.dart`](https://github.com/dart-lang/http/blob/master/pkgs/http/lib/src/io_client.dart) (Platform transports), [`pkgs/http/lib/retry.dart`](https://github.com/dart-lang/http/blob/master/pkgs/http/lib/retry.dart) (Retry client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP client"]
  node_http_api["HTTP API<br/>[http.dart]"]
  node_http_requests["Requests and responses<br/>[request.dart]"]
  node_http_transports["Platform transports<br/>[io_client.dart]"]
  node_http_retry["Retry client<br/>[retry.dart]"]
  node_http_multipart["Multipart requests"]
end

subgraph group_protocols["Protocols and servers"]
  node_http2["HTTP/2<br/>[connection.dart]"]
  node_http_parser["HTTP parser"]
  node_multi_server["Multi-server wrapper"]
  node_http_profile["Network profiling"]
end

subgraph group_native["Native clients"]
  node_cronet["Cronet client<br/>[cronet_client.dart]"]
  node_cupertino["Cupertino client"]
  node_okhttp["OkHttp client"]
end

subgraph group_websocket["WebSocket"]
  node_websocket_api["WebSocket API"]
  node_websocket_channel["Stream channel API"]
end

node_application(("Application"))
node_http_resource(("HTTP resource"))

node_application -->|"makes requests"| node_http_api
node_http_api -->|"consumes resources"| node_http_resource
node_http_api -.->|"composes"| node_http_requests
node_http_api -.->|"uses transport"| node_http_transports
node_http_api -.->|"supports retries"| node_http_retry
node_http_api -.->|"supports multipart"| node_http_multipart
node_application -.->|"uses HTTP/2"| node_http2
node_application -.->|"parses formats"| node_http_parser
node_application -.->|"serves requests"| node_multi_server
node_application -.->|"profiles traffic"| node_http_profile
node_application -.->|"selects client"| node_cronet
node_application -.->|"selects client"| node_cupertino
node_application -.->|"selects client"| node_okhttp
node_application -.->|"communicates over"| node_websocket_api
node_application -.->|"uses channel API"| node_websocket_channel

click node_http_api "https://github.com/dart-lang/http/blob/master/pkgs/http/lib/http.dart"
click node_http_requests "https://github.com/dart-lang/http/blob/master/pkgs/http/lib/src/request.dart"
click node_http_transports "https://github.com/dart-lang/http/blob/master/pkgs/http/lib/src/io_client.dart"
click node_http_retry "https://github.com/dart-lang/http/blob/master/pkgs/http/lib/retry.dart"
click node_http_multipart "https://github.com/dart-lang/http/blob/master/pkgs/http/lib/src/multipart_request.dart"
click node_http2 "https://github.com/dart-lang/http/blob/master/pkgs/http2/lib/src/connection.dart"
click node_http_parser "https://github.com/dart-lang/http/tree/master/pkgs/http_parser/lib"
click node_multi_server "https://github.com/dart-lang/http/tree/master/pkgs/http_multi_server/lib"
click node_http_profile "https://github.com/dart-lang/http/tree/master/pkgs/http_profile/lib"
click node_cronet "https://github.com/dart-lang/http/blob/master/pkgs/cronet_http/lib/src/cronet_client.dart"
click node_cupertino "https://github.com/dart-lang/http/blob/master/pkgs/cupertino_http/lib/src/cupertino_client.dart"
click node_okhttp "https://github.com/dart-lang/http/tree/master/pkgs/ok_http/lib"
click node_websocket_api "https://github.com/dart-lang/http/tree/master/pkgs/web_socket/lib"
click node_websocket_channel "https://github.com/dart-lang/http/tree/master/pkgs/web_socket_channel/lib"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_http_api,node_http_requests,node_http_transports,node_http_retry,node_http_multipart toneBlue
class node_http2,node_http_parser,node_multi_server,node_http_profile toneAmber
class node_cronet,node_cupertino,node_okhttp toneMint
class node_websocket_api,node_websocket_channel toneRose
class node_application,node_http_resource toneIndigo
```

## Components

### HTTP client

- [HTTP API](https://github.com/dart-lang/http/blob/master/pkgs/http/lib/http.dart): `pkgs/http/lib/http.dart`
- [Requests and responses](https://github.com/dart-lang/http/blob/master/pkgs/http/lib/src/request.dart): `pkgs/http/lib/src/request.dart`
- [Platform transports](https://github.com/dart-lang/http/blob/master/pkgs/http/lib/src/io_client.dart): `pkgs/http/lib/src/io_client.dart`
- [Retry client](https://github.com/dart-lang/http/blob/master/pkgs/http/lib/retry.dart): `pkgs/http/lib/retry.dart`
- [Multipart requests](https://github.com/dart-lang/http/blob/master/pkgs/http/lib/src/multipart_request.dart): `pkgs/http/lib/src/multipart_request.dart`

### Protocols and servers

- [HTTP/2](https://github.com/dart-lang/http/blob/master/pkgs/http2/lib/src/connection.dart): `pkgs/http2/lib/src/connection.dart`
- [HTTP parser](https://github.com/dart-lang/http/tree/master/pkgs/http_parser/lib): `pkgs/http_parser/lib`
- [Multi-server wrapper](https://github.com/dart-lang/http/tree/master/pkgs/http_multi_server/lib): `pkgs/http_multi_server/lib`
- [Network profiling](https://github.com/dart-lang/http/tree/master/pkgs/http_profile/lib): `pkgs/http_profile/lib`

### Native clients

- [Cronet client](https://github.com/dart-lang/http/blob/master/pkgs/cronet_http/lib/src/cronet_client.dart): `pkgs/cronet_http/lib/src/cronet_client.dart`
- [Cupertino client](https://github.com/dart-lang/http/blob/master/pkgs/cupertino_http/lib/src/cupertino_client.dart): `pkgs/cupertino_http/lib/src/cupertino_client.dart`
- [OkHttp client](https://github.com/dart-lang/http/tree/master/pkgs/ok_http/lib): `pkgs/ok_http/lib`

### WebSocket

- [WebSocket API](https://github.com/dart-lang/http/tree/master/pkgs/web_socket/lib): `pkgs/web_socket/lib`
- [Stream channel API](https://github.com/dart-lang/http/tree/master/pkgs/web_socket_channel/lib): `pkgs/web_socket_channel/lib`

### Other components

- **Application**
- **HTTP resource**

## Connections

- Application → HTTP API: makes requests (evidence: `README.md`)
- HTTP API → HTTP resource: consumes resources (evidence: `README.md`)
- HTTP API → Requests and responses: composes
- HTTP API → Platform transports: uses transport
- HTTP API → Retry client: supports retries
- HTTP API → Multipart requests: supports multipart
- Application → HTTP/2: uses HTTP/2
- Application → HTTP parser: parses formats
- Application → Multi-server wrapper: serves requests
- Application → Network profiling: profiles traffic
- Application → Cronet client: selects client
- Application → Cupertino client: selects client
- Application → OkHttp client: selects client
- Application → WebSocket API: communicates over
- Application → Stream channel API: uses channel API
