arturobernalg commented on code in PR #418:
URL:
https://github.com/apache/httpcomponents-client/pull/418#discussion_r1124939005
##########
httpclient5/src/main/java/org/apache/hc/client5/http/SystemDefaultDnsResolver.java:
##########
@@ -40,7 +40,23 @@ public class SystemDefaultDnsResolver implements DnsResolver
{
@Override
public InetAddress[] resolve(final String host) throws
UnknownHostException {
- return InetAddress.getAllByName(host);
+ try {
+ // Try resolving using the default resolver
+ return InetAddress.getAllByName(host);
+ } catch (final UnknownHostException e) {
+ // If default resolver fails, try stripping the IPv6 zone ID and
resolving again
+ String strippedHost = host;
+ if (host.charAt(0) == '[') {
+ final int i = host.lastIndexOf('%');
+ if (i != -1) {
+ strippedHost = host.substring(0, i) + "]";
+ }
+ }
+ if (!strippedHost.equals(host)) {
Review Comment:
@ok2c , there is no significant difference between the two code snippets you
provided. Both snippets attempt to strip the IPv6 zone ID from the host name if
it is present and retry the resolution if the default resolver fails.
But I any case, I made the change
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]