| 926 | } |
| 927 | |
| 928 | private static String toUriString(InetAddress addr) { |
| 929 | // InetAddresses.toUriString(addr) is almost enough but neglects RFC 6874 percent encoding. |
| 930 | String inetAddrStr = InetAddresses.toUriString(addr); |
| 931 | int percentIndex = inetAddrStr.indexOf('%'); |
| 932 | if (percentIndex < 0) { |
| 933 | return inetAddrStr; |
| 934 | } |
| 935 | |
| 936 | String scope = inetAddrStr.substring(percentIndex, inetAddrStr.length() - 1); |
| 937 | return inetAddrStr.substring(0, percentIndex) + percentEncode(scope, unreservedChars) + "]"; |
| 938 | } |
| 939 | |
| 940 | @CanIgnoreReturnValue |
| 941 | Builder setRawHost(String host) { |