Skip to content

Add connectHeaders to Proxy for HTTP CONNECT tunneling - #281

Merged
o-nnerb merged 3 commits into
mainfrom
feature/proxy-connect-headers
Aug 17, 2026
Merged

o-nnerb merged 3 commits into
mainfrom
feature/proxy-connect-headers

Conversation

@o-nnerb

@o-nnerb o-nnerb commented Aug 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds connectHeaders to Proxy, exposing async-http-client's connectHeaders (add proxy-header support swift-server/async-http-client#912, available since the pinned 1.36.0) — extra headers sent only on the HTTP CONNECT request used to establish the proxy tunnel.
  • connectHeaders is composed as a Property builder, the same way Form scopes its own per-part headers: Proxy becomes generic over Headers: Property, and a new init resolves that subtree via _makeProperty + search(for: HeaderNode.self) into a local HTTPHeaders value, entirely separate from the request's own headers.
  • Internals.Proxy gains a connectHeaders field, threaded only through the .http branch of build(). Excluded from Hashable — NIOHTTP1.HTTPHeaders isn't Hashable — mirroring how async-http-client's own Proxy type handles the same constraint.
  • The two existing initializers (authorization: and connection:) are unchanged, constrained to Headers == EmptyProperty.
DataTask {
    BaseURL("example.com")
    Proxy(host: "proxy.example.com", port: 8080) {
        CustomHeader(name: "X-Proxy-Token", value: "abc123")
    }
}

Marked breaking-changes because Proxy is now generic (Proxy<Headers: Property>) — source-compatible for every existing call site, but any code that spells the type explicitly (e.g. let p: Proxy) needs Proxy<EmptyProperty>.

Implements #279.

Test plan

  • swift test --filter RequestDLTests.ProxyTests
  • swift test --filter RequestDLInternalsTests.InternalsProxyTests
  • swift test (full suite, 1103 tests)
  • swift format lint --recursive --strict Sources Tests

Exposes async-http-client's connectHeaders (swift-server/async-http-client#912,
available since the pinned 1.36.0) through Proxy, composed as a Property builder
the same way Form scopes its own per-part headers — resolves the Headers subtree
via _makeProperty + search(for: HeaderNode.self) into a local HTTPHeaders value
instead of writing into the main request headers.

Internals.Proxy gains a connectHeaders field, threaded only through the .http
branch of build(); excluded from Hashable since NIOHTTP1.HTTPHeaders isn't,
mirroring how async-http-client's own Proxy handles the same constraint.

Implements #279.
@o-nnerb o-nnerb added the breaking-changes This PR is a new major version release label Aug 16, 2026
import RequestDLInternals sat between the doc block and the struct
declaration with no blank line, so the comment documented the import
statement instead of Proxy itself. Moved the import above the doc.
@o-nnerb
o-nnerb merged commit 8f13129 into main Aug 17, 2026
12 checks passed
@o-nnerb
o-nnerb deleted the feature/proxy-connect-headers branch August 17, 2026 10:56
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.24%. Comparing base (3c2f31d) to head (59c7496).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #281   +/-   ##
=======================================
  Coverage   98.24%   98.24%           
=======================================
  Files           3        3           
  Lines         857      857           
=======================================
  Hits          842      842           
  Misses         15       15           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

breaking-changes This PR is a new major version release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant