如何获取像“http://?????????.??”这样的西里尔文域 使用 Apache HTTP 客户端?

Pio*_*ler 1 java android http utf-8 apache-httpclient-4.x

使用httpclientfororg.apache.httpcomponents版本4.3.6我尝试对GET域名执行请求,例如http://?????????.??by new HttpGet(url),但最终出现以下错误:

Caused by: java.net.UnknownHostException: ?????????.??
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)
at java.net.InetAddress.getAllByName0(InetAddress.java:1255)
...
Run Code Online (Sandbox Code Playgroud)

url 变量具有正确的 UTF-8 值 - 它绝对不是从 '?' 建立起来的。人物。

如何向此类域名发送请求?

rek*_*ire 5

在解析域之前,您需要将域名编码为微不足道的代码。

final encodedDomain = IDN.toASCII(unicodeDomain);
Run Code Online (Sandbox Code Playgroud)

在此处查看 Android 文档:http : //developer.android.com/reference/java/net/IDN.html