-
Notifications
You must be signed in to change notification settings - Fork 125
Refactor URL component extraction #485
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
Conversation
Can one of the admins verify this patch? |
6 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
@swift-server-bot test this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, this makes sense, thanks. Do you mind very briefly adding tests that validate that empty socket paths are now rejected?
@swift-server-bot add to allowlist |
self.socketPath = try self.kind.socketPathFromURL(url) | ||
self.uri = self.kind.uriFromURL(url) | ||
|
||
(self.kind, self.host, self.socketPath, self.uri) = try Self.deconstructURL(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Thank you!
Would you mind returning the scheme
and port
in deconstructURL(_:)
as well?
scheme
is already a stored property in HTTPClient.Request
but port
not.
async-http-client/Sources/AsyncHTTPClient/HTTPHandler.swift
Lines 266 to 268 in 5dfbba8
public var port: Int { | |
return self.url.port ?? (self.useTLS ? 443 : 80) | |
} |
However, I don't mind adding
port
as another stored property. This would allow us to better reuse this functionality in the upcoming new HTTPClientRequest
for async/await support as described in this proposal:https://github.com/swift-server/async-http-client/blob/96872470475f18a5667fbf681e2e0f67ad8a0110/docs/async-await.md#new-httpclientrequest-type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karwa friendly ping 🙂
I would like to use your changes soon. Do you have any estimate when you have time to work on this again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll address the comments now and update the patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! One small change and we are good to go from my side.
CI is currently flaky because I turned parallel testing on. Fix is on its way (#498) so don't worry if you see any test in HTTPClientSOCKSTests
failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great change! Thanks!
Co-authored-by: Fabian Fett <[email protected]>
This is currently split across 4 functions (well, 3 functions and an initialiser). It's much easier to understand how AHC understands these URL formats if it happens in a single function (especially since schemes like
http+unix
are not standardised).Additionally, this rejects empty HTTP hostnames, as they are invalid per the spec, and empty socket paths, since they are meaningless.