本文整理匯總了Java中io.netty.handler.codec.http.HttpHeaders.getHost方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpHeaders.getHost方法的具體用法?Java HttpHeaders.getHost怎麽用?Java HttpHeaders.getHost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.handler.codec.http.HttpHeaders
的用法示例。
在下文中一共展示了HttpHeaders.getHost方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRequestURI
import io.netty.handler.codec.http.HttpHeaders; //導入方法依賴的package包/類
private String getRequestURI(FullHttpRequest request) {
String uri = request.getUri();
if (uri.startsWith("/")) {
String host = HttpHeaders.getHost(request);
if (host != null && !host.isEmpty()) {
uri = "https://" + host + uri;
}
}
return uri;
}
示例2: isProxyRequest
import io.netty.handler.codec.http.HttpHeaders; //導入方法依賴的package包/類
protected boolean isProxyRequest(FullHttpRequest req) {
String host = HttpHeaders.getHost(req);
if (host == null || host.isEmpty()) {
return true;
}
String[] values = host.split(":");
if (values.length < 2) {
return true;
}
String hostName = values[0];
String port = values[1];
if (!port.equals(String.valueOf(m_appConfig.getProxyPort()))) {
return true;
}
try {
InetAddress target = InetAddress.getByName(hostName);
Enumeration<NetworkInterface> eni = null;
eni = NetworkInterface.getNetworkInterfaces();
while (eni.hasMoreElements()) {
NetworkInterface n = eni.nextElement();
Enumeration<InetAddress> eia = n.getInetAddresses();
while (eia.hasMoreElements()) {
InetAddress current = eia.nextElement();
if (current.equals(target)) {
return false;
}
}
}
} catch (UnknownHostException | SocketException e) {
LOGGER.warn(e.getMessage());
}
return true;
}