-
Notifications
You must be signed in to change notification settings - Fork 122
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
Obtain Response URL #790
Comments
Unfortunately, this information is not exposed today. We'd need some new API surface on the response to expose it, which in my view should also expose the rest of the redirect history. |
This is particularly bumpy problem when trying to replace |
|
@Lukasa, I'll probably take a stab at this. In var visitedURLs: [String]
var url: String? {
get {
self.visitedURLs.last
}
} or actually pairing a url with its corresponding var visitedURLs: [(url: String, head: HTTPResponseHead)] or something really wild var visitedURLs: [(request: HTTPClient.Request, head: HTTPResponseHead)] |
So we should definitely avoid using a non-nominal type here, so I think the tuples are out: they will be hard to evolve if we want to add other things. I wonder if we should go whole-hog and offer: var history: [RedirectedRequest]
struct RedirectedRequest {
var request: HTTPClient.Request
var response: HTTPResponseHead
} |
That could work! There are some cases where we would have no history (for example, no redirects occur), and we'd still want to be able to access the We could rename this struct something like /// The target URL after redirects
var url: URL? {
get {
self.history.last?.request.url
}
} Another cause for concern: none of the func didReceiveHead(task: HTTPClient.Task<Response>, _ head: HTTPResponseHead, _ request: HTTPClient.Request) -> EventLoopFuture<Void> Would we need the |
Your proposal generally sounds reasonable. Extending the delegate should probably be done in a separate PR to avoid making the size get out of hand, as it will require somewhat meaningful surgery and testing. The name you propose is fine, but we do still want it to return a Future to enable delaying the I/O. |
Trying to pave the way for closing #790 with some direction from @Lukasa. I have no idea where is best to insert this new delegate method. I'm currently doing it first thing in `receiveResponseHead0`, and not using an EventLoopFuture for back pressure management. The state machine seems pretty fragile and I don't want to leave too much of an imprint. Trying to be a part of an EventLoopFuture chain seems really complicated and would really leave a mark on the codebase, so I'm wondering if it's possible to just warn the user "do not block"? Anyway, just a jumping-off point and happy to take direction!
how can I get the response url?
in URLSession we can say:
how to do that using AsyncHttpClient?
The text was updated successfully, but these errors were encountered: