Skip to content

Conversation

@rnro
Copy link
Collaborator

@rnro rnro commented Oct 2, 2024

Foundation.URL has various behavior changes in Swift 6 to better match RFC 3986 which impact AHC.

In particular it now no longer strips the square brackets in IPv6 hosts which are not tolerated by inet_pton so these must be manually stripped.

swiftlang/swift-foundation#957 - Initializing a URL from an IPv6 address in Swift 6 on Linux now does not strip enclosing square-brackets.
swiftlang/swift-foundation#958 - Initializing a URL from a unix file path in Swift 6 on Linux now returns a non-nil value (an empty String).
swiftlang/swift-foundation#962 - Initializing a URL from an empty string in Swift 6 on Linux now returns a non-nil URL value.

@rnro rnro force-pushed the foundation_url_behavior_changes branch 3 times, most recently from 6b61458 to 8cf9960 Compare October 3, 2024 08:47

switch scheme {
case .http, .https:
#if os(Linux) && compiler(>=6.0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the wrong check: it's if !canImport(Darwin)

switch scheme {
case .http, .https:
#if os(Linux) && compiler(>=6.0)
guard var urlHost = url.host, !urlHost.isEmpty else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
guard var urlHost = url.host, !urlHost.isEmpty else {
guard let urlHost = url.host, !urlHost.isEmpty else {

let request3 = try Request(url: "unix:///tmp/file")
XCTAssertNil(request3.url.host)
XCTAssertEqual(request3.host, "")
#if os(Linux) && compiler(>=6.0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note here.

`Foundation.URL` has various behavior changes in Swift 6 to better match RFC 3986 which impact AHC.

In particular it now no longer strips the square brackets in IPv6 hosts
which are not tolerated by `inet_pton` so these must be manually
stripped.
@rnro rnro force-pushed the foundation_url_behavior_changes branch from 8cf9960 to ee5009a Compare October 3, 2024 09:56
@rnro rnro enabled auto-merge (squash) October 3, 2024 10:01
@rnro rnro merged commit 0a9b723 into swift-server:main Oct 3, 2024
@rnro rnro added the 🔨 semver/patch No public API change. label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants