Make HTTPFields hashing consistent with equality (#143)

## Summary

HTTPFields equality does not depend on the order of differently named
fields. Hashing used storage order, so equal values could hash
differently.

This hashes each name group in relative order, then mixes those group
hashes without depending on name order. The existing hash test now
asserts equal hashes.

Fixes #139
This commit is contained in:
Hashim Khan authored and GitHub committed 2026-09-03 13:55:14 +00:00
1 parent 6aff14dae9
commit dfebed0b4e
2 files changed
+15 -6

No files matched your search

+1 -5
View File
@@ -279,11 +279,7 @@ extension HTTPField.Name {
.acceptEncoding: "gzip",
]
#expect(fields1 == fields2)
// Equal values must therefore hash equally.
withKnownIssue("HTTPFields.hash(into:) is order sensitive while == is not") {
#expect(fields1.hashValue == fields2.hashValue)
}
#expect(fields1.hashValue == fields2.hashValue)
}
@Test func sendable() {