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

[SR-9887] HTTPCookie on Linux does not accept Substring values #3542

Closed
swift-ci opened this issue Feb 8, 2019 · 3 comments
Closed

[SR-9887] HTTPCookie on Linux does not accept Substring values #3542

swift-ci opened this issue Feb 8, 2019 · 3 comments

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Feb 8, 2019

Previous ID SR-9887
Radar None
Original Reporter djones6 (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: c9d5bc0021712729bd7fe8e2cae62b9f

Issue Description:

The following code successfully creates an HTTPCookie on Darwin, whereas on Linux the initializer returns nil:

let cookie = HTTPCookie(properties: [.domain: ".", .path: "/", .name: "Davey".dropLast(), .value: "Jonesy".dropLast()])
if let cookie = cookie {
    print("\(cookie)")
} else {
    print("No cookie :(")
}

The initializer takes values as Any, so this code compiles, but fails silently. The initializer in SCLF is trying to cast the values to String:

public init?(properties: [HTTPCookiePropertyKey : Any]) {

Is it expected that you should be able to pass a Substring here, and should the cast be to something like StringProtocol instead?

@belkadan
Copy link

belkadan commented Feb 8, 2019

cc @milseman, @millenomi

@swift-ci
Copy link
Contributor Author

swift-ci commented Mar 8, 2019

Comment by sai Hema k (JIRA)

HTTPCookiePropertyKey does not restricts the type of the value to be String only. Based on the Darwin behavior I believe the substring is acceptable and the current behavior is a bug .

@spevans
Copy link
Collaborator

spevans commented Jan 23, 2020

This was fixed in 5.0.

PR: #2022

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants