Skip to content

s-celles/PureHTTP2.jl

PureHTTP2.jl

Pure-Julia HTTP/2 libraryRFC 9113 and RFC 7541, covering both server and client roles, cross-tested against libnghttp2 via Nghttp2Wrapper.jl.

Ask DeepWiki CI Docs: stable Docs: dev Version License

About

PureHTTP2.jl is a standalone implementation of HTTP/2 written entirely in Julia. It was extracted from the http2 submodule of gRPCServer.jl and developed as a reusable library under the PureHTTP2.jl constitution: pure Julia only, TDD with TestItemRunner.jl, reference parity with libnghttp2, Keep a Changelog + Semantic Versioning, and warning-free Documenter.jl builds.

[deps] in Project.toml is empty: PureHTTP2.jl has zero runtime dependencies beyond Julia's standard library. Optional TLS / ALPN support is provided via a package extension that loads when OpenSSL.jl is present in the same environment.

Installation

using Pkg
Pkg.add("PureHTTP2")

Minimum Julia version: 1.10. The test/interop/ cross-test environment against Nghttp2Wrapper.jl requires Julia ≥ 1.12 separately.

A minimal example — h2c client

using PureHTTP2, Sockets

# Connect to a local h2c server (e.g., Nghttp2Wrapper.HTTP2Server).
tcp = connect(IPv4("127.0.0.1"), 8080)

conn = HTTP2Connection()
result = PureHTTP2.open_connection!(conn, tcp;
    request_headers = Tuple{String, String}[
        (":method",    "GET"),
        (":path",      "/"),
        (":scheme",    "http"),
        (":authority", "127.0.0.1:8080"),
    ])

println("status  = ", result.status)
println("headers = ", result.headers)
println("body    = ", String(result.body))

close(tcp)

For the server-side counterpart, see docs/src/tls.md and PureHTTP2.serve_connection!. For TLS / ALPN support via the optional OpenSSL extension, see docs/src/client.md.

What's supported

  • Frame layer — encode / decode for all RFC 9113 §6 frame types (DATA, HEADERS, PRIORITY, RST_STREAM, SETTINGS, PUSH_PROMISE, PING, GOAWAY, WINDOW_UPDATE, CONTINUATION).
  • HPACK — encoder / decoder with dynamic table and Huffman compression, cross-validated against 23,688 conformance cases from http2jp/hpack-test-case.
  • Stream state machine — RFC 9113 §5 transitions with odd / even stream-ID parity enforcement.
  • Connection lifecycle — preface exchange, SETTINGS negotiation, flow control, GOAWAY, graceful shutdown.
  • Server-role IO entry pointserve_connection!(conn, io) drives a server over any Base.IO satisfying the IO adapter contract (read(io, n::Int), write(io, bytes), close(io)).
  • Client-role IO entry pointopen_connection!(conn, io; request_headers, request_body) drives a single client-role request / response exchange over the same contract.
  • Optional TLS ALPN helperPureHTTP2.set_alpn_h2!(ctx) provided by the PureHTTP2OpenSSLExt package extension when OpenSSL.jl is loaded. Converts a Vector{String} protocol list into RFC 7301 §3.1 wire format and hands it to OpenSSL's ssl_set_alpn.
  • Reference parity against libnghttp2 — 14 Interop: @testitem units in test/interop/ cross-test PureHTTP2.jl against Nghttp2Wrapper.jl, including a live h2c TCP round trip in each direction (server-role and client-role).
  • Documentation — 10-page Documenter.jl site with warning-free builds enforced from Milestone 1 onward.

Current limitations

At v0.1.0, the following are deliberately not yet shipped:

  • Server-side h2 TLS ALPN — blocked on an upstream OpenSSL.jl binding gap for SSL_CTX_set_alpn_select_cb. The client-side ALPN helper (set_alpn_h2!) works end-to-end; the server side cannot yet negotiate h2 in a TLS handshake. Tracked in upstream-bugs.md.
  • Multi-request client sessionsopen_connection! ships a single-request API. Stream multiplexing and long-lived sessions over one connection are a post-v0.1.0 concern.
  • Affirmative server push handlingopen_connection! and serve_connection! negotiate SETTINGS_ENABLE_PUSH = 0 and treat any PUSH_PROMISE as a connection-level PROTOCOL_ERROR per RFC 9113 §8.4. Accepting, processing, or explicitly refusing pushed streams is out of scope.
  • Multi-frame request bodiesrequest_body is a single Vector{UInt8} written as one DATA frame. Chunked / streamed uploads are deferred.
  • macOS / Windows CI — the CI matrix is Linux-only at v0.1.0. PureHTTP2.jl is pure Julia and should work on other platforms, but it is not yet tested there.
  • Stream priority beyond best-effort (RFC 9113 §5.3), extensible SETTINGS per RFC 7540 §6.5.2, performance benchmarks, and a fuzz harness — all deferred to post-v0.1.0 milestones. See ROADMAP.md.

Links

License

PureHTTP2.jl is distributed under the MIT License. See the Provenance appendix in CHANGELOG.md for the extraction history and license inheritance from gRPCServer.jl.

Acknowledgements

PureHTTP2.jl was lifted and shifted from the http2 submodule of gRPCServer.jl at commit 4abc0932. Reference parity is validated against the C implementation libnghttp2 via Nghttp2Wrapper.jl.

About

[WIP] Pure Julia HTTP2 library

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Languages