本文整理汇总了Java中io.netty.handler.codec.http.HttpHeaders.contains方法的典型用法代码示例。如果您正苦于以下问题:Java HttpHeaders.contains方法的具体用法?Java HttpHeaders.contains怎么用?Java HttpHeaders.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.handler.codec.http.HttpHeaders
的用法示例。
在下文中一共展示了HttpHeaders.contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modifyResponseHeadersToReflectProxying
import io.netty.handler.codec.http.HttpHeaders; //导入方法依赖的package包/类
/**
* If and only if our proxy is not running in transparent mode, modify the
* response headers to reflect that it was proxied.
*
* @param httpResponse
* @return
*/
private void modifyResponseHeadersToReflectProxying(
HttpResponse httpResponse) {
if (!proxyServer.isTransparent()) {
HttpHeaders headers = httpResponse.headers();
stripConnectionTokens(headers);
stripHopByHopHeaders(headers);
ProxyUtils.addVia(httpResponse, proxyServer.getProxyAlias());
/*
* RFC2616 Section 14.18
*
* A received message that does not have a Date header field MUST be
* assigned one by the recipient if the message will be cached by
* that recipient or gatewayed via a protocol which requires a Date.
*/
if (!headers.contains(HttpHeaders.Names.DATE)) {
HttpHeaders.setDate(httpResponse, new Date());
}
}
}
示例2: switchProxyConnectionHeader
import io.netty.handler.codec.http.HttpHeaders; //导入方法依赖的package包/类
/**
* Switch the de-facto standard "Proxy-Connection" header to "Connection"
* when we pass it along to the remote host. This is largely undocumented
* but seems to be what most browsers and servers expect.
*
* @param headers
* The headers to modify
*/
private void switchProxyConnectionHeader(HttpHeaders headers) {
String proxyConnectionKey = "Proxy-Connection";
if (headers.contains(proxyConnectionKey)) {
String header = headers.get(proxyConnectionKey);
headers.remove(proxyConnectionKey);
headers.set(HttpHeaders.Names.CONNECTION, header);
}
}
示例3: 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);
}
}
}
}
}
示例4: isPreflightRequest
import io.netty.handler.codec.http.HttpHeaders; //导入方法依赖的package包/类
private static boolean isPreflightRequest(final HttpRequest request) {
final HttpHeaders headers = request.headers();
return request.method().equals(HttpMethod.OPTIONS) &&
headers.contains(HttpHeaderNames.ORIGIN) &&
headers.contains(HttpHeaderNames.ACCESS_CONTROL_REQUEST_METHOD);
}