swift-http-types icon indicating copy to clipboard operation
swift-http-types copied to clipboard

Concatenating fields inconsistent with docs

Open 0xTim opened this issue 8 months ago • 1 comments

According the docs setting multiple fields for the same header should append each field in a comma-separated list (unless it's a cookie). However

var headers = HTTPFields()
headers[.date] = "\(Date(timeIntervalSinceReferenceDate: 100.0))"
headers[.date] = "\(Date(timeIntervalSinceReferenceDate: -100.0))"
print(headers)

Only shows the last set date:

[(field: Date: 2000-12-31 23:58:20 +0000, next: 65535)]

Should it not show both dates? If you use headers[values: .date] = [...] it works as expected:

[(field: Date: 2001-01-01 00:01:40 +0000, next: 1), (field: Date: 2000-12-31 23:58:20 +0000, next: 65535)]

0xTim avatar Mar 09 '25 23:03 0xTim