Skip to content

Add initial HTTP client tests#78

Merged
xbhatnag merged 26 commits intoapple:mainfrom
xbhatnag:client-tests
Feb 6, 2026
Merged

Add initial HTTP client tests#78
xbhatnag merged 26 commits intoapple:mainfrom
xbhatnag:client-tests

Conversation

@xbhatnag
Copy link
Collaborator

@xbhatnag xbhatnag commented Feb 2, 2026

Added the following tests:

statusOutOfRangeButValid()
customHeader()
stressTest()
echoInterleave()
echoString()
redirect308()
gzip()
brotli()
deflate()
identity()
ok()
redirect301()
notFound()
getConvenience()
postConvenience()

Added these tests as well, but they currently hang/crash, so they have been temporarily disabled:

cancelPreBody()
cancelPreHeaders()
emptyChunkedBody()

Cover basic methods (GET, POST), content-encoding (gzip, brotli), redirection (301,308), not found (404), out-of-range, timeout (darwin-specific) and a basic stress test
Also use predefined header names instead of manual initialization.
Disable non-functional tests, rename tests, remove unnecessary assertions
This test currently causes a crash, but will be fixed in a separate commit.
This one focuses on hang after getting the response headers, but no body
`HTTPServer` -> `HTTPServerForTesting`
`httpClient` -> `HTTP`
`AsyncWriter.writeAndConclude` -> `AsyncWriter.write`
`RedirectionHandler` -> `Options.redirectionHandlerClosure`
WIthout this, Xcode complains that the server is only available on 26.2 or later.
It's only testing Darwin-specific behavior and we have no ability to set a timeout currently.
Use camelCast instead of snake_case
@xbhatnag xbhatnag self-assigned this Feb 2, 2026
@xbhatnag xbhatnag added the 🔨 semver/patch No public API change. label Feb 2, 2026
@xbhatnag xbhatnag linked an issue Feb 2, 2026 that may be closed by this pull request
Use “stall” instead of “hang”
@xbhatnag xbhatnag added ⚠️ semver/major Breaks existing public API. and removed 🔨 semver/patch No public API change. labels Feb 2, 2026
@xbhatnag xbhatnag added 🔨 semver/patch No public API change. and removed ⚠️ semver/major Breaks existing public API. labels Feb 2, 2026
Store server task and cancel it on deinit.
Parameterize on HTTP methods for the OK 200 test
Client can request an encoding that is not supported by the server. The server is allowed to fallback to no encoding (identity), which the client must also handle.
We don't want to enforce brotli support in the client, but we also don’t have a way to query for support from the client implementation such that we can conditionally enable the brotli test.

Disabling until we get an answer for this.
Rather than enforcing that a client should support specific content-encodings, if the client does not specify the expected encoding, then the server will give the body in plaintext, causing the test to pass.
Copy link
Contributor

@guoye-zhang guoye-zhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine other than a few nits

We use `withKnownIssue` to mark a test as “failed but still OK” if we see that the Content-Encoding is “identity” or not present.
@xbhatnag xbhatnag enabled auto-merge (squash) February 3, 2026 20:22
@xbhatnag xbhatnag disabled auto-merge February 3, 2026 20:23
@xbhatnag xbhatnag merged commit 72c5c5b into apple:main Feb 6, 2026
21 checks passed
@xbhatnag xbhatnag deleted the client-tests branch February 6, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a compliance test suite

3 participants