Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@ rebar3 eunit --verbose
rebar3 dialyzer
```

## Finding Your Way

[Where Things Live](guides/code_map.md) maps each concept to its modules and
tests. The table below tells you where to start for common changes.

| If you want to | Start in | Check with |
|----------------|----------|------------|
| Add a request option | `src/hackney.erl`, then `src/hackney_conn.erl` | `hackney_integration_tests`, plus the HTTP/2 and HTTP/3 tests if the option applies there |
| Change pool or checkout behaviour | `src/hackney_pool.erl`, `src/hackney_load_regulation.erl` | `hackney_pool_tests` and the fault and chaos suites in [DEVELOPMENT.md](DEVELOPMENT.md) |
| Change HTTP/2 or HTTP/3 behaviour | `src/hackney_conn.erl`, `src/hackney_h3.erl`. Check first whether the fix belongs in the `h2` or `quic` dependency | `hackney_http2_*_tests`, `hackney_http3_*_tests`, `hackney_h3_*_tests` |
| Change the HTTP/1.1 parser | `src/hackney_http.erl` | `hackney_http_tests`, `hackney_header_limits_tests`, `hackney_chunk_limit_tests` |
| Add a proxy type or transport | `src/hackney_http_connect.erl`, `src/hackney_socks5.erl`, `src/hackney_tcp.erl` | `hackney_proxy_tests`, `hackney_socks5_tests` |
| Add a function to the public API | `src/hackney.erl` | A test in `test/`, and the matching guide in `guides/` |
| Bump a dependency | `rebar.config`, then `rebar3 upgrade --all` | `rebar3 eunit`, `rebar3 xref`, `rebar3 dialyzer` |

Put tests in `test/`. Do not export functions from `src/` only for tests.

## Code Style

- Follow existing code conventions
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Types: `fix`, `feat`, `docs`, `test`, `refactor`, `ci`, `chore`
## Continuous Integration

CI runs on:
- Linux x86_64 (OTP 27.2, 28.0)
- Linux x86_64 (OTP 27.2, 28.0, 29.0)
- Linux ARM64 (OTP 27.2)
- macOS ARM64 (OTP 27)
- FreeBSD 14.2 (OTP 28)
Expand Down
24 changes: 24 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# NEWS

4.12.2 - 2026-11-20
-------------------

### Changed

- quic 3.2.0, h2 0.18.3 and webtransport 0.5.12.
- HTTP/3: on a resumed connection, only GET, HEAD, OPTIONS and TRACE
requests are sent as 0-RTT. A request with another method now waits
for the handshake, because 0-RTT data can be replayed. It still
succeeds, one round trip later.
- Documentation: the Design Guide now describes the current connection
states, TLS pooling and HTTP/2 handling, and a new "Where Things Live"
page maps each part of hackney to its modules and tests.

### Fixed

- HTTP/3 and WebTransport: a small write or the end of a stream could
reach the server ahead of data still waiting to be sent on the same
stream. Writes now leave in the order they were made.
- HTTP/3: sending on many streams of one connection no longer slows
down as the amount of queued data grows.
- HTTP/2: a request answered with a malformed response now fails at
once instead of waiting for the timeout.

4.12.1 - 2026-11-15
-------------------

Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ Payload = <<"{\"key\": \"value\"}">>,
| [WebSocket Guide](guides/websocket_guide.md) | Connect, send, receive, active mode |
| [WebTransport Guide](guides/webtransport_guide.md) | Streams, datagrams, multiplexing, server handlers |
| [Design Guide](guides/design.md) | Architecture, pooling, load regulation internals |
| [Migration Guide](guides/MIGRATION.md) | Upgrading from hackney 1.x |
| [Where Things Live](guides/code_map.md) | Which modules and tests implement each concept |
| [Migration Guide](guides/MIGRATION.md) | Upgrading from hackney 1.x and 2.x |
| [API Reference](https://hexdocs.pm/hackney) | Full module documentation |
| [Changelog](NEWS.md) | Version history |

Expand Down Expand Up @@ -307,15 +308,14 @@ This applies to HTTP/1.1, HTTP/2 and HTTP/3.

## Modules

| Module | Purpose |
|--------|---------|
| `hackney` | Main API - requests, connections, WebSocket |
| `hackney_pool` | Connection pool management |
| `hackney_url` | URL parsing and encoding |
| `hackney_headers` | Header manipulation |
| `hackney_multipart` | Multipart encoding |
| `hackney_cookie` | Cookie parsing |
| `hackney_http` | HTTP protocol parser |
You call `hackney` for requests, WebSocket (`ws_*`), WebTransport (`wt_*`) and
HTTP/2 streams (`h2_*`), and `hackney_pool` to configure pools. `hackney_url`,
`hackney_headers`, `hackney_multipart` and `hackney_cookie` are helpers you can
use on their own.

If you want to change hackney itself, start with
[Where Things Live](guides/code_map.md): it maps each concept to its modules
and tests.

## Requirements

Expand Down
4 changes: 0 additions & 4 deletions TODO.md

This file was deleted.

66 changes: 66 additions & 0 deletions guides/code_map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Where Things Live

This page maps each part of hackney to the modules that implement it and the
tests that cover it. Use it when you want to change hackney or follow a bug
into the source: find the concept, open the module, run the tests listed next
to it. For how the parts work together, read the [Design Guide](design.md)
first.

## How a request travels

1. `hackney:request/5` (`src/hackney.erl`) parses the URL and options, runs
the middleware chain, and asks for a connection.
2. `hackney_load_regulation` takes a per-host slot, then `hackney_pool` hands
out a connection process.
3. `hackney_conn` owns the socket. It sends the request and reads the response
for HTTP/1.1 itself, through the `h2` dependency for HTTP/2, and through
`hackney_h3` and the `quic` dependency for HTTP/3.
4. When the response is read, an HTTP/1.1 connection goes back to the pool or
closes. HTTP/2 and HTTP/3 connections stay registered in the pool and are
shared by every caller for that host.

## Map

Source modules are in `src/`. Test modules are in `test/` and end in `_tests`,
so `hackney_pool` below means `test/hackney_pool_tests.erl`.

| Concept | Modules | Tests |
|---------|---------|-------|
| Public API | `hackney` | `hackney_integration`, `hackney_query`, `hackney_redirect`, `hackney_send_request` |
| Connection process | `hackney_conn`, `hackney_conn_sup` | `hackney_conn`, `hackney_direct_owner`, `hackney_close_hang`, `hackney_recv_timeout` |
| Pool and concurrency | `hackney_pool`, `hackney_load_regulation`, `hackney_keepalive` | `hackney_pool`, `hackney_pool_fault`, `hackney_pool_h2h3_fault`, `hackney_pool_chaos`, `hackney_pool_safety`, `hackney_load_regulation` |
| HTTP/1.1 wire format | `hackney_http`, `hackney_headers`, `hackney_multipart`, `hackney_cookie`, `hackney_deflate` | `hackney_http`, `hackney_header_limits`, `hackney_chunk_limit`, `hackney_max_body_size`, `hackney_multipart` |
| HTTP/2 | `hackney_conn` (functions prefixed `h2_`), `hackney_h2_stream` | `hackney_http2_*`, `hackney_h2_bidi` |
| HTTP/3 | `hackney_h3`, `hackney_altsvc`, `hackney_conn` (functions prefixed `h3_`) | `hackney_http3_*`, `hackney_h3_*`, `hackney_altsvc`, `hackney_pool_h3` |
| TLS | `hackney_ssl`, `hackney_ssl_certificate` | `hackney_ssl`, `hackney_ssl_alpn`, `hackney_insecure`, `hackney_tls_resumption_race` |
| Connecting | `hackney_happy`, `hackney_tcp`, `hackney_local_tcp`, `hackney_cidr` | `hackney_happy`, `hackney_connect_race`, `hackney_pool_unix_socket` |
| Proxies | `hackney_http_connect`, `hackney_socks5` | `hackney_proxy`, `hackney_https_proxy`, `hackney_http_connect`, `hackney_socks5` |
| WebSocket | `hackney_ws`, `hackney_ws_proto` | `hackney_ws`, `hackney_ws_proto` |
| WebTransport | `hackney_wt` | `hackney_wt` |
| Middleware | `hackney_middleware` | `hackney_middleware`, `hackney_middleware_integration` |
| URLs and helpers | `hackney_url`, `hackney_bstr`, `hackney_date`, `hackney_util`, `hackney_trace` | `hackney_url`, `hackney_bstr`, `hackney_date`, `hackney_util`, `hackney_trace` |

Run one test module with:

```sh
rebar3 eunit --module=hackney_pool_tests
```

## What is public and what is internal

You can rely on `hackney`, `hackney_pool`, `hackney_url`, `hackney_headers`,
`hackney_multipart`, `hackney_cookie` and the `hackney_middleware` behaviour.
The other modules are internal and can change between releases.

## Notes

- `hackney_conn` is the largest module. Its states are separated by `State:`
banner comments; the HTTP/2 and HTTP/3 code is in functions prefixed `h2_`
and `h3_`. Read the state machine section of the Design Guide before
changing it.
- HTTP/2 framing, QUIC and WebTransport are not implemented here. They come
from the `h2`, `quic` and `webtransport` dependencies. If a bug is in
framing or flow control, it probably belongs there.
- `test/` also holds test servers (`hackney_h3_test_server`,
`mock_proxy_server`), the fault harness described in the Development guide,
and reproduction harnesses (`repro_h1_hang`, `repro_h2_hang`).
Loading
Loading