Skip to content

Commit 06b966d

Browse files
committed
fix: compliance test suite fixes
1 parent f12ea76 commit 06b966d

9 files changed

Lines changed: 289 additions & 268 deletions

File tree

README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,15 @@ HTTP/1.1 and HTTP/2 support. Pure Erlang. Zero dependencies.
1111

1212
## Why?
1313

14-
- **Fast**: Optimized for performance with inline compilation and buffer tuning
15-
- **Simple**: Small API surface, easy to understand
16-
- **Correct**: Proper HTTP/1.1 and HTTP/2 protocol handling
17-
- **Flexible**: Works with both protocols transparently
14+
Fast. Small API. Proper HTTP/1.1 and HTTP/2 support. Works with both protocols transparently.
1815

1916
Built to replace `httpc` with better performance and cleaner code.
2017

2118
## HTTP/2 Compliance
2219

23-
**156 compliance tests** covering RFC 7540 (HTTP/2) and RFC 7541 (HPACK)
20+
**156 tests** covering RFC 7540 (HTTP/2) and RFC 7541 (HPACK). All frame types, stream states, flow control, priority handling, HPACK compression, and error conditions.
2421

25-
- Complete frame type validation (DATA, HEADERS, SETTINGS, PING, etc.)
26-
- Stream state machine verification
27-
- Flow control and priority handling
28-
- HPACK compression/decompression
29-
- All error conditions tested
30-
31-
Tested against [h2-client-test-harness](https://github.com/nomadlabsinc/h2-client-test-harness) with **100% pass rate**.
22+
Tested against [h2-client-test-harness](https://github.com/nomadlabsinc/h2-client-test-harness). **100% pass rate**.
3223

3324
## Quick Start
3425

include/gen_http.hrl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
| {headers, request_ref(), headers()}
1111
| {data, request_ref(), binary()}
1212
| {done, request_ref()}.
13-
-type socket() :: term().
13+
-type socket() :: gen_tcp:socket() | ssl:sslsocket().
1414

1515
-define(DEFAULT_PROTOCOLS, [http1, http2]).

src/gen_http.erl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
%% @doc Unified interface for HTTP/1.1 and HTTP/2 connections.
44
%%
5-
%% This module provides protocol-agnostic functions that work with both
6-
%% gen_http_h1 and gen_http_h2 connections.
5+
%% Protocol-agnostic functions that work with both gen_http_h1 and gen_http_h2.
76

87
%% Compiler optimizations for hot-path functions
98
-compile(inline).
@@ -370,7 +369,7 @@ get_socket(Conn) when is_tuple(Conn) ->
370369

371370
%% @doc Store a private key-value pair in the connection.
372371
%%
373-
%% This allows users to attach metadata to connections (e.g., pool ID, metrics, tags).
372+
%% Attach metadata to connections (e.g., pool ID, metrics, tags).
374373
%% Works with both HTTP/1.1 and HTTP/2 connections.
375374
%%
376375
%% ## Examples

src/gen_http_h1.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
%% @doc HTTP/1.1 connection state machine.
55
%%
6-
%% This module implements a process-less HTTP/1.1 client with support for:
6+
%% Process-less HTTP/1.1 client. Supports:
77
%% - Request pipelining
88
%% - Keep-alive connections
99
%% - Chunked transfer encoding
1010
%% - Body streaming (request and response)
1111
%%
12-
%% The connection state is a pure data structure passed between function calls.
12+
%% Connection state is a pure data structure passed between function calls.
1313

1414
%% Compiler optimizations for hot-path functions
1515
-compile(inline).
@@ -310,7 +310,7 @@ get_socket(#gen_http_h1_conn{socket = Socket}) ->
310310

311311
%% @doc Store a private key-value pair in the connection.
312312
%%
313-
%% This allows users to attach metadata to connections (e.g., pool ID, metrics, tags).
313+
%% Attach metadata to connections (e.g., pool ID, metrics, tags).
314314
-spec put_private(conn(), Key :: term(), Value :: term()) -> conn().
315315
put_private(#gen_http_h1_conn{private = Private} = Conn, Key, Value) ->
316316
Conn#gen_http_h1_conn{private = maps:put(Key, Value, Private)}.

src/gen_http_h2.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
%% @doc HTTP/2 connection state machine.
55
%%
6-
%% This module implements a process-less HTTP/2 client with support for:
6+
%% Process-less HTTP/2 client. Supports:
77
%% - Stream multiplexing (multiple concurrent requests)
88
%% - Flow control (connection and stream level)
99
%% - Settings negotiation
1010
%% - HPACK header compression
1111
%% - Server push
1212
%% - GOAWAY handling
1313
%%
14-
%% The connection state is a pure data structure passed between function calls.
14+
%% Connection state is a pure data structure passed between function calls.
1515

1616
%% Compiler optimizations for hot-path functions
1717
-compile(inline).
@@ -367,7 +367,7 @@ get_socket(#gen_http_h2_conn{socket = Socket}) ->
367367

368368
%% @doc Store a private key-value pair in the connection.
369369
%%
370-
%% This allows users to attach metadata to connections (e.g., pool ID, metrics, tags).
370+
%% Attach metadata to connections (e.g., pool ID, metrics, tags).
371371
-spec put_private(conn(), Key :: term(), Value :: term()) -> conn().
372372
put_private(#gen_http_h2_conn{private = Private} = Conn, Key, Value) ->
373373
Conn#gen_http_h2_conn{private = maps:put(Key, Value, Private)}.

src/gen_http_parser_hpack.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
%% @doc HPACK: Header Compression for HTTP/2 (RFC 7541).
44
%%
5-
%% This module implements HPACK header compression with static and dynamic tables.
6-
%% The compression context is pure data (no process state).
5+
%% HPACK header compression with static and dynamic tables.
6+
%% Compression context is pure data (no process state).
77
%%
8-
%% Huffman encoding is enabled by default and automatically used when it
9-
%% reduces the string size (typically ~30% compression for header values).
8+
%% Huffman encoding is used when it reduces string size
9+
%% (typically ~30% compression for header values).
1010

1111
-export([
1212
new/0,

test/README.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ This directory contains tests for the gen_http HTTP client library.
44

55
## Test Infrastructure
66

7-
Tests use a local Docker-based infrastructure instead of making requests to external websites. This provides:
8-
9-
- **Reliability**: Tests don't fail due to network issues
10-
- **Speed**: Local requests are much faster
11-
- **Control**: We control the test server behavior
12-
- **Privacy**: No external requests during development
7+
Tests run against local Docker containers instead of hitting external websites. This means tests won't randomly fail from network issues, they run faster, and you're not leaking requests during development.
138

149
### Test Server Setup
1510

@@ -65,19 +60,19 @@ docker compose -f test/support/docker-compose.yml down -v
6560

6661
## Test Server Endpoints
6762

68-
The local httpbin service provides the following endpoints:
63+
httpbin gives you these endpoints:
6964

7065
- `GET /get` - Returns GET request data
7166
- `POST /post` - Returns POST request data
7267
- `GET /status/{code}` - Returns specified HTTP status code
7368
- `GET /delay/{seconds}` - Delays response
7469
- `GET /redirect/{n}` - 302 redirect n times
7570
- `POST /anything` - Returns anything sent
76-
- And many more (see [httpbin.org](https://httpbin.org/) for full API)
71+
- Plus more at [httpbin.org](https://httpbin.org/)
7772

7873
## Configuration
7974

80-
Test server ports can be configured via environment variables:
75+
Change ports with environment variables:
8176

8277
- `HTTPBIN_HTTP_PORT` (default: 8080) - HTTP server port
8378
- `HTTPBIN_HTTPS_PORT` (default: 8443) - HTTPS server port
@@ -101,15 +96,11 @@ If tests are being skipped with "Test server not available", ensure:
10196

10297
### Port conflicts
10398

104-
If ports 8080 or 8443 are already in use:
105-
106-
1. Stop conflicting services
107-
2. Or change ports in `.env` file
108-
3. Restart Docker Compose
99+
If ports 8080 or 8443 are already in use, either stop whatever's using them or change the ports in `.env` and restart docker compose.
109100

110101
### SSL certificate errors
111102

112-
The Caddy server uses self-signed certificates for local testing. Tests should use the `verify_none` SSL option:
103+
Caddy uses self-signed certificates for local testing. Use `verify_none` in your tests:
113104

114105
```erlang
115106
{ok, Conn} = gen_http:connect(https, "localhost", 8443, #{

0 commit comments

Comments
 (0)