本文整理匯總了Java中io.netty.handler.codec.http.HttpHeaders.getAll方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpHeaders.getAll方法的具體用法?Java HttpHeaders.getAll怎麽用?Java HttpHeaders.getAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.handler.codec.http.HttpHeaders
的用法示例。
在下文中一共展示了HttpHeaders.getAll方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addHeaders
import io.netty.handler.codec.http.HttpHeaders; //導入方法依賴的package包/類
private void addHeaders(HttpHeaders headers, HttpRequestResource resource) {
log.debug("HTTP HEADERS:");
for (String name : headers.names()) {
if (name.toUpperCase().startsWith("CIBET_")) continue;
String headerName = name.toLowerCase();
List<String> headerValues = headers.getAll(name);
if (headerValues.size() == 1) {
log.debug(headerName + " = " + headerValues.get(0));
resource.addParameter(headerName, headerValues.get(0), ParameterType.HTTP_HEADER);
} else {
if (log.isDebugEnabled()) {
for (String v : headerValues) {
log.debug(headerName + " = " + v);
}
}
String[] strValues = headerValues.toArray(new String[headerValues.size()]);
resource.addParameter(headerName, strValues, ParameterType.HTTP_HEADER);
}
}
}
示例2: stripConnectionTokens
import io.netty.handler.codec.http.HttpHeaders; //導入方法依賴的package包/類
/**
* RFC2616 Section 14.10
*
* HTTP/1.1 proxies MUST parse the Connection header field before a message
* is forwarded and, for each connection-token in this field, remove any
* header field(s) from the message with the same name as the
* connection-token.
*
* @param headers
* The headers to modify
*/
private void stripConnectionTokens(HttpHeaders headers) {
if (headers.contains(HttpHeaders.Names.CONNECTION)) {
for (String headerValue : headers.getAll(HttpHeaders.Names.CONNECTION)) {
for (String connectionToken : ProxyUtils.splitCommaSeparatedHeaderValues(headerValue)) {
// do not strip out the Transfer-Encoding header if it is specified in the Connection header, since LittleProxy does not
// normally modify the Transfer-Encoding of the message.
if (!LOWERCASE_TRANSFER_ENCODING_HEADER.equals(connectionToken.toLowerCase(Locale.US))) {
headers.remove(connectionToken);
}
}
}
}
}