當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpHeaders.contains方法代碼示例

本文整理匯總了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());
        }
    }
}
 
開發者ID:wxyzZ,項目名稱:little_mitm,代碼行數:29,代碼來源:ClientToProxyConnection.java

示例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);
    }
}
 
開發者ID:wxyzZ,項目名稱:little_mitm,代碼行數:17,代碼來源:ClientToProxyConnection.java

示例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);
                }
            }
        }
    }
}
 
開發者ID:wxyzZ,項目名稱:little_mitm,代碼行數:25,代碼來源:ClientToProxyConnection.java

示例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);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:7,代碼來源:Netty4CorsHandler.java


注:本文中的io.netty.handler.codec.http.HttpHeaders.contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。