Skip to content

Add new conformance tests for headers and redirection#110

Merged
xbhatnag merged 8 commits intomainfrom
new-tests
Feb 25, 2026
Merged

Add new conformance tests for headers and redirection#110
xbhatnag merged 8 commits intomainfrom
new-tests

Conversation

@xbhatnag
Copy link
Collaborator

@xbhatnag xbhatnag commented Feb 23, 2026

Motivation

Improve conformance coverage for uncommon header values and infinite HTTP redirection taking inspiration from existing tests and HTTP RFC specs.

Modifications

Added 5 tests:

  • Empty Header Values: Clients must allow headers with empty values. (RFC 9112 §5)
  • Infinite Redirection: A client must not get stuck in a redirection loop and must instead throw an error after a maximum number of redirect follow attempts.
  • Head-with-Content-Length: A client that makes a HEAD request should mark the request as completed upon receiving the headers, regardless of fields like Content-Length (RFC 9112 §6.3, rule 1)
  • Client + Server multi-value headers: Clients must be able to send/receive headers with the same key and multiple values.

Result

These tests pass with the URLSession implementation of HTTPClient.

Test Plan

Manually verified some of this behavior with curl.

@xbhatnag xbhatnag added the 🔨 semver/patch No public API change. label Feb 23, 2026
@guoye-zhang
Copy link
Contributor

The invalid header value is actually stripped by HTTPRequest, not by URLSession.

One test we could do is whether multi-value fields are preserved, but URLSession won't pass it today.

@xbhatnag
Copy link
Collaborator Author

One test we could do is whether multi-value fields are preserved, but URLSession won't pass it today.

PTAL at the new multi-value tests, URLSession seems to pass those fine?

…new-tests

# Conflicts:
#	Sources/HTTPClientConformance/HTTPClientConformance.swift
@xbhatnag
Copy link
Collaborator Author

One test we could do is whether multi-value fields are preserved, but URLSession won't pass it today.

PTAL at the new multi-value tests, URLSession seems to pass those fine?

Given our conversation above, merging multi-value fields is an optional feature that our tests allow, because some clients may choose to do so.

Later on when we write tests for cookies, we can also ensure that this merging does not apply to Set-Cookie.

@xbhatnag xbhatnag merged commit 34ab843 into main Feb 25, 2026
18 of 21 checks passed
@xbhatnag xbhatnag deleted the new-tests branch February 25, 2026 18:13
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.

2 participants