mirror of
https://github.com/apple/swift-http-types
synced 2026-11-25 04:47:48 +00:00
Field order should be insignificant between fields of different names
This commit is contained in:
1 parent
68deedb6b9
commit
4c7d1331a5
2 files changed
+66
-1
No files matched your search
@@ -108,7 +108,29 @@ public struct HTTPFields: Sendable, Hashable {
|
||||
}
|
||||
|
||||
static func == (lhs: _Storage, rhs: _Storage) -> Bool {
|
||||
lhs.fields.lazy.map(\.0) == rhs.fields.lazy.map(\.0)
|
||||
let leftFieldsIndex = lhs.ensureIndex
|
||||
let rightFieldsIndex = rhs.ensureIndex
|
||||
if leftFieldsIndex.count != rightFieldsIndex.count {
|
||||
return false
|
||||
}
|
||||
for (name, var leftIndex) in leftFieldsIndex {
|
||||
guard var rightIndex = rightFieldsIndex[name] else {
|
||||
return false
|
||||
}
|
||||
while leftIndex != .max && rightIndex != .max {
|
||||
let (leftField, leftNext) = lhs.fields[Int(leftIndex)]
|
||||
let (rightField, rightNext) = rhs.fields[Int(rightIndex)]
|
||||
if leftField != rightField {
|
||||
return false
|
||||
}
|
||||
leftIndex = leftNext
|
||||
rightIndex = rightNext
|
||||
}
|
||||
if leftIndex != rightIndex {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func append(field: HTTPField) {
|
||||
|
||||
Reference in new issue
Block a user