ok2c commented on code in PR #418:
URL:
https://github.com/apache/httpcomponents-client/pull/418#discussion_r1124702424
##########
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:
@arturobernalg In fact if you use null to signify a case when the original
host is unchanged (not stripped) and no second DNS is not needed you can put
this code into a separate method as before, if you like it better that way.
--
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]