apple / apple/swift-http-types
Concatenating fields inconsistent with docs
- Dominant language
- Swift
- Stars
- 1k
- Forks
- 80
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 12
Description
According the [docs](https://github.com/apple/swift-http-types/blob/main/Sources/HTTPTypes/HTTPFields.swift#L161) setting multiple fields for the same header should append each field in a comma-separated list (unless it's a cookie). However
```swift
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)]
```
Contributor guide
Research direction
Start in Sources/HTTPTypes/HTTPFields.swift at the documentation linked in the issue, then reproduce the two assignments to the .date field and compare them with the values: subscript example. Done means the single-value assignment behavior matches the documented comma-separated handling for non-cookie fields, with the issue's date example demonstrating both values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100