Skip to content

Support HTTP.jl 2.x alongside 1.x#775

Open
krynju wants to merge 6 commits into
JuliaCloud:masterfrom
krynju:http2-support-github
Open

Support HTTP.jl 2.x alongside 1.x#775
krynju wants to merge 6 commits into
JuliaCloud:masterfrom
krynju:http2-support-github

Conversation

@krynju

@krynju krynju commented Jun 24, 2026

Copy link
Copy Markdown

Summary

Adds support for HTTP.jl 2.x while retaining 1.x, selected at load time via a small compatibility layer. Project.toml now declares HTTP = "1, 2".

HTTP.jl 2.0 is a breaking release; the relevant changes for AWS.jl are bridged in src/utilities/http_compat.jl (feature-flagged on the presence of the HTTP.Exceptions submodule, which exists only on 1.x):

  • StatusError constructor changed from (status, method, target, response)(status, response).
  • RequestError, iserror, isbytes, resource, and the HTTP.Exceptions submodule were removed — HTTP.isrecoverable and local shims replace them.
  • Response bodies are buffered as Vector{UInt8} (1.x exposed a stream object when a response_stream was supplied), header names are canonicalized, and connection-attempt timeouts surface as TimeoutError rather than ConnectError.

Tests construct version-appropriate exceptions/bodies. The IMDS mock no longer reimplements HTTP.jl's private retry internals (which differ across versions) and instead honors only the retry_check path IMDS actually relies on.

GitHub.jl / HTTP 2 interaction

GitHub.jl (used only by the parse_aws_metadata API-generation tooling) is retained as a dependency. Registered GitHub.jl currently pins HTTP < 2, so with GitHub.jl present the resolver selects HTTP 1.x today. Once GitHub.jl publishes a release with HTTP 1+2 support, HTTP 2 resolves with no further change (widen the GitHub compat bound if that support arrives in a new major version).

Note: the first commit temporarily replaced GitHub.jl with hand-rolled REST calls to unblock HTTP 2 immediately; the second commit restores GitHub.jl. The net change to src/api_generation/ versus master is none. Happy to squash before merge.

Testing

Unit suite passes under both HTTP 1.11 and HTTP 2.4 (the latter exercised by temporarily dropping GitHub.jl to allow HTTP 2 resolution).

🤖 Generated with Claude Code

krynju and others added 3 commits June 22, 2026 14:04
HTTP.jl 2.0 is a breaking release. Add a compatibility layer so AWS.jl
works on both 1.x and 2.x, selected at load time via a feature flag.

Client-side changes (src/utilities/http_compat.jl + call sites):
- `StatusError` constructor changed from (status, method, target, response)
  to (status, response).
- `RequestError`, `iserror`, `isbytes`, `resource`, and the `HTTP.Exceptions`
  submodule were removed; use `HTTP.isrecoverable` and local shims.
- Response bodies are buffered as bytes (no `IOBuffer` bodies), header names
  are canonicalized, and connection timeouts surface as `TimeoutError`
  rather than `ConnectError`.

Drop the GitHub.jl dependency: it pins HTTP < 2 and was used only by the
API-generation tooling. Its three REST calls (authenticate/tree/blob) are
reimplemented over HTTP + JSON.

Tests updated to construct version-appropriate exceptions/bodies. The IMDS
mock no longer replicates HTTP.jl's private retry internals (which differ
across versions) and instead honors only the retry_check path IMDS relies on.

Verified: unit suite passes under both HTTP 1.11 and HTTP 2.4.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bring GitHub.jl back as a dependency and revert the API-generation tooling
to use it (the hand-rolled GitHub REST shim from the HTTP 2 work is removed).
This keeps all the HTTP.jl 1.x/2.x client compatibility from the parent branch
while using GitHub.jl for `parse_aws_metadata`.

Note: registered GitHub.jl (v5) still pins HTTP < 2, so with this dependency
the resolver currently selects HTTP 1.x. Once GitHub.jl publishes a release
with HTTP 1+2 support, HTTP 2 resolves without further changes (widen the
`GitHub` compat bound if that support arrives in a new major version).

Verified: unit suite passes (HTTP 1.11 + GitHub.jl).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The test helpers gated their HTTP 1.x/2.x branches on an inline
`isdefined(HTTP, :Exceptions)`, duplicating the detection that
`AWS._HTTP_V2` already centralizes. Reference the package flag instead so
version detection has a single source of truth.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@krynju
krynju marked this pull request as ready for review June 24, 2026 10:20
krynju and others added 3 commits June 25, 2026 10:17
The IMDSv2 token PUT runs with `retry=false`; a hop-limit rejection manifests
as a read timeout. On HTTP.jl 2.x that read-deadline timeout can surface as an
`HTTP.TimeoutError` (the same way connection timeouts do — `is_connection_exception`
already handles that), not only as a bare `ETIMEDOUT` `IOError`. Without this,
`is_ttl_expired_exception` returns false, the IMDSv1 fallback is skipped, and the
token fetch hard-fails in hop-limited (container) environments. Match
`HTTP.TimeoutError` in the 2.x branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`_HTTP_V2 = !isdefined(HTTP, :Exceptions)` is no longer reliable: HTTP 2.x
re-adds `HTTP.Exceptions` as a deprecating compat shim (JuliaWeb/HTTP.jl#1315),
so on a 2.x release carrying that shim the flag would flip to `false` and AWS.jl
would silently run its 1.x code paths on HTTP 2. Switch to `pkgversion(HTTP) >= 2`
(with an `HTTP.EmptyBody` feature-detection fallback for Julia < 1.9 — a genuine
2.x-only type that is not shimmed back).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`HTTP.VERSION` only exists from HTTP.jl 2.0 on; under 1.x it resolves to the `VERSION` re-exported from `Base` (the Julia version). Guard with `Base.binding_module` before comparing, and bound to the 2.x line (`v"2" <= VERSION < v"3"`) so a future HTTP 3 isn't treated as 2.x. Replaces the prior version-detection.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@krynju
krynju force-pushed the http2-support-github branch from 4aa049a to db23e1d Compare June 26, 2026 07:14
@tanmaykm
tanmaykm requested review from ericphanson and omus June 29, 2026 09:42
@ericphanson

Copy link
Copy Markdown
Member

I'm not super familiar with http v2 vs v1 but the code looks more or less reasonable to me. However I think something that would de-risk this a lot is if you updated CI to run on BOTH major versions of HTTP. This would ensure we are truly compatible with both.

We have done that before with Onda.jl and its dependency on Arrow, see

https://github.com/beacon-biosignals/Onda.jl/blob/b8b7720549c35cb57ee587b30a1b610065304253/.github/workflows/CI.yml#L27-L29

https://github.com/beacon-biosignals/Onda.jl/blob/b8b7720549c35cb57ee587b30a1b610065304253/.github/workflows/CI.yml#L39-L45

and I think something similar could probably done here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants