ureq 3.x improve resolver
Closed this issue · 1 comments
algesten commented
This is the current Resolver trait.
pub trait Resolver: Debug + Send + Sync + 'static {
fn resolve(
&self,
uri: &Uri,
config: &AgentConfig,
timeout: NextTimeout,
) -> Result<SocketAddr, Error>;
}
The biggest problem is to only return a single SocketAddr
. In testing ureq 3.x I'm trying to use an nginx server bound to localhost:8080
, and it turns out the server is only listening to IPv4. However macOS resolves localhost
primarily to IPv6. It seems overly simplistic to return a single address. We need to return "a number" of addresses that can be attempted in turn and check for the Io(Os { code: 61, kind: ConnectionRefused, message: "Connection refused" })
error to try the next.
algesten commented
smallvec
is already a dep (via hoot), I suggest we use a fixed number of address slots as return type via SmallVec
. Something like 10-16 would be enough.