Repository navigation
Conversation
Export `TunnelError` from `connect::proxy`, so a caller can downcast the error of a failed `CONNECT` and classify it without matching error text. `TunnelError::status()` returns the status of a refused `CONNECT`. `TunnelError::proxy_authenticate()` returns the `Proxy-Authenticate` values of a 407 response. The error stays opaque, so more information can come later as new methods.
Member
|
I don't think I want to export a new error type. I do welcome improving the error messages that get reported. |
Author
@seanmonstar |
Author
|
Error messages will give at most but its not matchable, without a contract (the error type i suggest) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
when a CONNECT through
Tunnelfails, you get aTunnelErrorback, but the type isn't exported, so the only thing you can really do with it is read the message. two cases bit me:Proxy-Authenticateheaders, so there's no way to know if the proxy wants Negotiate, NTLM or Basicthis PR exports
TunnelErrorand adds two methods:status()gives the status the proxy answered with (Some(407)for auth required), orNoneif there wasn't a valid oneproxy_authenticate()gives theProxy-Authenticatevalues of a 407 as-is, no parsingi went with an opaque struct (the old variants are now a private kind) because of what you wrote in #162 and in the pattern matching post, so more stuff can be added later as methods without breaking anyone.
Displayandsource()are the same as before, so anyone matching on the log text is fine.Tunnel's response type isn't touched, and it merges cleanly with #320.one thing to be upfront about: someone could already name the type through
<Tunnel<C> as Service<Uri>>::Errorand match on the variants, and that would stop compiling. i couldn't find anyone doing it and cargo-semver-checks is happy, but wanted to say it.how i think it can help: reqwest uses
Tunnelfor https through a proxy, and people keep hitting this (seanmonstar/reqwest#2252, astral-sh/uv#23284). with this, a reqwest user can walksource(), downcast toTunnelError, and e.g. tell the user "your proxy wants NTLM" or "the proxy blocked this (403)" instead of "tunnel error: unsuccessful". it only needs acargo update, nothing changes in reqwest. i checked that with reqwest 0.13.5 against a small local proxy.