本文整理了Java中okhttp3.internal.Util.canonicalizeHost()
方法的一些代码示例,展示了Util.canonicalizeHost()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.canonicalizeHost()
方法的具体详情如下:
包路径:okhttp3.internal.Util
类名称:Util
方法名:canonicalizeHost
[英]If host is an IP address, this returns the IP address in canonical form.
Otherwise this performs IDN ToASCII encoding and canonicalize the result to lowercase. For example this converts ☃.net to xn--n3h.net, and WwW.GoOgLe.cOm to www.google.com. null will be returned if the host cannot be ToASCII encoded or if the result contains unsupported ASCII characters.
[中]如果主机是一个IP地址,则返回标准形式的IP地址。
否则将执行IDN ToASCII编码,并将结果规范化为小写。例如,这个转换☃.净到xn--n3h。net和WwW.GoOgLe。cOm访问www.google。通用域名格式。如果主机无法进行ASCII编码,或者结果包含不支持的ASCII字符,则将返回null。
代码示例来源:origin: square/okhttp
private Builder domain(String domain, boolean hostOnly) {
if (domain == null) throw new NullPointerException("domain == null");
String canonicalDomain = Util.canonicalizeHost(domain);
if (canonicalDomain == null) {
throw new IllegalArgumentException("unexpected domain: " + domain);
}
this.domain = canonicalDomain;
this.hostOnly = hostOnly;
return this;
}
代码示例来源:origin: square/okhttp
private static @Nullable String canonicalizeHost(String input, int pos, int limit) {
// Start by percent decoding the host. The WHATWG spec suggests doing this only after we've
// checked for IPv6 square braces. But Chrome does it first, and that's more lenient.
String percentDecoded = percentDecode(input, pos, limit, false);
return Util.canonicalizeHost(percentDecoded);
}
代码示例来源:origin: square/okhttp
/**
* Returns a domain string like {@code example.com} for an input domain like {@code EXAMPLE.COM}
* or {@code .example.com}.
*/
private static String parseDomain(String s) {
if (s.endsWith(".")) {
throw new IllegalArgumentException();
}
if (s.startsWith(".")) {
s = s.substring(1);
}
String canonicalDomain = canonicalizeHost(s);
if (canonicalDomain == null) {
throw new IllegalArgumentException();
}
return canonicalDomain;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
private Builder domain(String domain, boolean hostOnly) {
if (domain == null) throw new NullPointerException("domain == null");
String canonicalDomain = Util.canonicalizeHost(domain);
if (canonicalDomain == null) {
throw new IllegalArgumentException("unexpected domain: " + domain);
}
this.domain = canonicalDomain;
this.hostOnly = hostOnly;
return this;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
/**
* Returns a domain string like {@code example.com} for an input domain like {@code EXAMPLE.COM}
* or {@code .example.com}.
*/
private static String parseDomain(String s) {
if (s.endsWith(".")) {
throw new IllegalArgumentException();
}
if (s.startsWith(".")) {
s = s.substring(1);
}
String canonicalDomain = canonicalizeHost(s);
if (canonicalDomain == null) {
throw new IllegalArgumentException();
}
return canonicalDomain;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
private static @Nullable String canonicalizeHost(String input, int pos, int limit) {
// Start by percent decoding the host. The WHATWG spec suggests doing this only after we've
// checked for IPv6 square braces. But Chrome does it first, and that's more lenient.
String percentDecoded = percentDecode(input, pos, limit, false);
return Util.canonicalizeHost(percentDecoded);
}
代码示例来源:origin: com.github.ljun20160606/okhttp
private Builder domain(String domain, boolean hostOnly) {
if (domain == null) throw new NullPointerException("domain == null");
String canonicalDomain = Util.canonicalizeHost(domain);
if (canonicalDomain == null) {
throw new IllegalArgumentException("unexpected domain: " + domain);
}
this.domain = canonicalDomain;
this.hostOnly = hostOnly;
return this;
}
代码示例来源:origin: apache/servicemix-bundles
private Builder domain(String domain, boolean hostOnly) {
if (domain == null) throw new NullPointerException("domain == null");
String canonicalDomain = Util.canonicalizeHost(domain);
if (canonicalDomain == null) {
throw new IllegalArgumentException("unexpected domain: " + domain);
}
this.domain = canonicalDomain;
this.hostOnly = hostOnly;
return this;
}
代码示例来源:origin: apache/servicemix-bundles
private static String canonicalizeHost(String input, int pos, int limit) {
// Start by percent decoding the host. The WHATWG spec suggests doing this only after we've
// checked for IPv6 square braces. But Chrome does it first, and that's more lenient.
String percentDecoded = percentDecode(input, pos, limit, false);
return Util.canonicalizeHost(percentDecoded);
}
代码示例来源:origin: com.github.ljun20160606/okhttp
private static String canonicalizeHost(String input, int pos, int limit) {
// Start by percent decoding the host. The WHATWG spec suggests doing this only after we've
// checked for IPv6 square braces. But Chrome does it first, and that's more lenient.
String percentDecoded = percentDecode(input, pos, limit, false);
return Util.canonicalizeHost(percentDecoded);
}
代码示例来源:origin: com.github.ljun20160606/okhttp
/**
* Returns a domain string like {@code example.com} for an input domain like {@code EXAMPLE.COM}
* or {@code .example.com}.
*/
private static String parseDomain(String s) {
if (s.endsWith(".")) {
throw new IllegalArgumentException();
}
if (s.startsWith(".")) {
s = s.substring(1);
}
String canonicalDomain = canonicalizeHost(s);
if (canonicalDomain == null) {
throw new IllegalArgumentException();
}
return canonicalDomain;
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Returns a domain string like {@code example.com} for an input domain like {@code EXAMPLE.COM}
* or {@code .example.com}.
*/
private static String parseDomain(String s) {
if (s.endsWith(".")) {
throw new IllegalArgumentException();
}
if (s.startsWith(".")) {
s = s.substring(1);
}
String canonicalDomain = canonicalizeHost(s);
if (canonicalDomain == null) {
throw new IllegalArgumentException();
}
return canonicalDomain;
}
内容来源于网络,如有侵权,请联系作者删除!