Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concatenating fields inconsistent with docs #94

Open
0xTim opened this issue Mar 9, 2025 · 1 comment
Open

Concatenating fields inconsistent with docs #94

0xTim opened this issue Mar 9, 2025 · 1 comment

Comments

@0xTim
Copy link
Contributor

0xTim commented Mar 9, 2025

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)]
@guoye-zhang
Copy link
Contributor

The comment is referring to the behavior of get. It would be a confusing behavior if setting a value actually appends it. If you want to set multi-value fields, subscript(values:) is the correct method to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants