feat(runtime): isolate HTTPRuntime target#1121
Open
grdsdev wants to merge 22 commits into
Open
Conversation
…e deleted SSE parser after the package-scoping edit The manual public->package access-control pass left HTTPRuntime non-compiling: checkStatus still referenced HTTPResponse's now-removed bare status/isSuccess (now only on .head), MultipartFormData's new builder API members defaulted to internal instead of package, and ServerSentEvents.swift was deleted outright rather than rescoped, breaking SSE stream parsing entirely.
Follow-up to the HTTPRuntime target isolation: registers the test target in the shared Xcode scheme, adds its spell-check terms, and updates Package.resolved to drop dependencies no longer pulled in by this trimmed-down package graph.
…ase, add addHeader - HTTPTransport.send/stream now throw typed HTTPError instead of any Error; URLSessionTransport already only ever threw HTTPError.transport, so this just tightens the contract. Dropped the redundant `throws` on the private makeURLRequest helper, which never actually threw. - Removed HTTPBody.multipart: callers now build the multipart body themselves via MultipartFormData.buildToTempFile(), set Content-Type, and pass .file. Keeps HTTPTransport from needing to know about multipart assembly. - Added HTTPRequestBuilder.addHeader(_:value:), which merges into an existing header (joined with "; ") instead of replacing it, for repeated directives like Prefer. Both setHeader and addHeader resolve the target key case-insensitively so differently-cased calls merge into one header instead of creating duplicates.
Supabase's own clients don't need it; downstream consumers can parse the raw streamed chunks themselves if they want SSE framing.
…sed doc references - checkStatus now requires a catch-all APIError type instead of falling back to a bare unexpectedStatus(status:body:) case, and reports decode failures as unexpectedResponse(response:underlyingError:) with the full response attached. - Commented out the still-unused HTTPError.encoding case. - Dropped doc comments referencing the (now removed) OpenAPI codegen tool.
…uild - TransferProgress/ProgressHandler were left `public` when the rest of HTTPRuntime was scoped down to `package`; the capability-matrix CI check flagged them as new, unregistered public API. Scope them to `package` like everything else in this target. - FoundationNetworking (swift-corelibs-foundation on Linux) has no async byte-streaming API (`bytes(for:)`/`AsyncBytes`), so URLSessionTransport.stream() failed to compile on Linux. Branch on `canImport(FoundationNetworking)`: Linux buffers the full response via `data(for:)` and yields it as a single chunk instead of streaming incrementally; Apple platforms keep the existing incremental byte-stream implementation.
…RuntimeTestHelpers
…e and dictionary Adds HTTPRuntimeTestHelpersTests to the shared Xcode scheme in alphabetical order between HelpersTests and HTTPRuntimeTests. Includes dictionary.txt entries for Xcode-related terms and formatting fixes to HTTPRuntimeTestHelpers source files.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Isolates the zero-dependency
HTTPRuntimetarget out of #1099 into its own branch, plus a few follow-up refinements requested during review, and adds a first-partyHTTPRuntimeTestHelperstarget for stubbingHTTPRuntimerequests under Swift Testing.HTTPRuntimeSources/HTTPRuntime(HTTP request/response types,URLSessionTransport, multipart form assembly, JSON coding) andTests/HTTPRuntimeTests, without the OpenAPI codegen tool or generated Storage client from the original PR.HTTPRuntimeTestsin the shared Xcode scheme andswift6TestTargets, and adds its spell-check terms.HTTPTransport.send/streamnow use typed throws (throws(HTTPError)) instead ofany Error—URLSessionTransportalready only ever threwHTTPError.transport, so this tightens the contract to match. Dropped the redundantthrowson the privatemakeURLRequesthelper, which never actually threw.HTTPBody.multipart: callers now assemble the multipart body themselves viaMultipartFormData.buildToTempFile(), setContent-Type, and pass.file. Keeps the transport from needing to know about multipart assembly.HTTPRequestBuilder.addHeader(_:value:), which merges into an existing header (joined with"; ") instead of replacing it — for repeated directives likePrefer. BothsetHeaderandaddHeaderresolve the target key case-insensitively (linear scan over the small header set) so differently-cased calls merge instead of duplicating.ServerSentEvents.swift) — not needed by Supabase's clients.stream()branches per platform:FoundationNetworking(Linux) lacksURLSession.bytes(for:), so it falls back to a buffered single-chunk delivery there instead of true incremental streaming.HTTPRuntimeTestHelpers(new)HTTPStub/HTTPStubBody: canned-response definitions, one static factory per HTTP verb (.get/.post/.put/.patch/.delete/.head), body as.empty/.string/.data/.stream.HTTPTransportStub: an actor conforming toHTTPTransport— an ordered, consume-once stub queue with aTaskLocal-backed.currentaccessor, safe under parallel Swift Testing runs..http(stubs:): a customTestTrait/SuiteTraitbinding the stub queue to a test's task tree, usable at@Testor@Suitelevel and composable across nesting (suite-level stubs are consumed before test-level ones).curlCommand(for:): renders anHTTPRequestas a curl command (mirrorsSources/TestHelpers/URLRequestSnapshot.swift's conventions, independently, so this target has no dependency onTestHelpers).assertHTTPRequests { operation } matches: { curlSnapshot }: asserts an inline curl snapshot of whatever requestsoperationmade, viaInlineSnapshotTesting.HTTPRuntimeTestHelpersTestsin the shared Xcode scheme andswift6TestTargets.docs/superpowers/specs/2026-07-11-http-runtime-test-helpers-design.md.Test plan
swift buildswift test --filter HTTPRuntimeTests(9 tests)swift test --filter HTTPRuntimeTestHelpersTests(18 tests)./scripts/spell-check.sh./scripts/format.sh(no changes)swift:6.1image)