Replies: 1 comment
|
Implementado em #281 — |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Overview
async-http-clientmergedconnectHeaderssupport for HTTP proxies in PR #912, released in1.36.0— already the version this package pins (Package.swift: from: "1.30.2",Package.resolvedcurrently locked to1.36.0), so nothing upstream is blocking this.HTTPClient.Configuration.Proxynow carries aconnectHeaders: HTTPHeadersproperty: extra headers sent only on theCONNECTrequest used to establish the tunnel through an HTTP proxy (e.g.X-Proxy-Tokenfor caller attribution), never on the actual request the tunnel then carries.hostandproxy-authorizationstay reserved — upstream always sets/overrides those two regardless of what's passed — and duplicate values under the same name are preserved on the wire. SOCKS proxies have noCONNECTphase, so the option doesn't apply there; upstream's own.socksServer(host:port:)factory has noconnectHeadersparameter at all.RequestDL's
Proxyproperty (Properties/Sources/Session/Proxy/Proxy.swift) has no way to reach this today —Internals.Proxy.build()(Internals/Sources/Session/Proxy/Internals.Proxy.swift) only ever calls.server(host:port:),.server(host:port:authorization:), or.socksServer(host:port:), none of which touchconnectHeaders.API
Add
connectHeadersas a trailing, defaulted parameter to the existing authorization initializer — the one already implicitly HTTP-only (it hardcodesconnectionProtocol = .http, same constraintconnectHeadersneeds):Plus a second, auth-less overload for the "headers without proxy credentials" case:
Both source-compatible additions — no existing call site changes shape. Uses RequestDL's own public
HTTPHeaders(Tasks/Sources/Raw Task/Upload/Models/HTTPHeaders.swift): alreadyExpressibleByDictionaryLiteral, already preserves repeated values under the same name (matches the upstream test assertingX-Proxy-Tokenadded twice), already hasbuild() -> NIOHTTP1.HTTPHeaders.The existing
init(host:port:connection:)(the one that accepts.socks) stays untouched —connectHeadersis deliberately only reachable from the HTTP-only initializers, mirroring upstream's own split between.server(...)and.socksServer(...).Wiring
Internals.Proxygains aconnectHeaders: RequestDL.HTTPHeadersfield (default[:]), read only by the.httpbranch ofbuild():Proxy.Node/Proxy._makePropertythreadconnectHeadersstraight through, same shapeauthorizationalready has.Out of scope (v1)
connectHeaders— noCONNECTphase to attach them to; upstream doesn't offer it either.host/proxy-authorizationoverride validation on RequestDL's side — upstream already silently drops those two reserved names itself (HTTP1ProxyConnectHandler.reservedConnectHeaders), so duplicating the check here would just be dead code.SystemProxyintegration —SystemProxy.swiftresolves proxy settings from the OS and has no per-proxy custom-header source to draw from; unaffected by this proposal.Milestone: 4.1.0
All reactions