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

workaround Foundation.URL behavior changes #777

Merged
merged 1 commit into from
Oct 3, 2024

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
@@ -48,9 +48,16 @@ extension DeconstructedURL {

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)

@@ -48,9 +48,16 @@ extension DeconstructedURL {

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 {

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
6 of 7 checks passed
@rnro rnro added the semver/patch For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1) 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 For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants