当前位置: 首页>>代码示例>>Java>>正文


Java HttpHeaders.setDate方法代码示例

本文整理汇总了Java中io.netty.handler.codec.http.HttpHeaders.setDate方法的典型用法代码示例。如果您正苦于以下问题:Java HttpHeaders.setDate方法的具体用法?Java HttpHeaders.setDate怎么用?Java HttpHeaders.setDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.handler.codec.http.HttpHeaders的用法示例。


在下文中一共展示了HttpHeaders.setDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeAuthenticationRequired

import io.netty.handler.codec.http.HttpHeaders; //导入方法依赖的package包/类
private void writeAuthenticationRequired(String realm) {
    String body = "<!DOCTYPE HTML \"-//IETF//DTD HTML 2.0//EN\">\n"
            + "<html><head>\n"
            + "<title>407 Proxy Authentication Required</title>\n"
            + "</head><body>\n"
            + "<h1>Proxy Authentication Required</h1>\n"
            + "<p>This server could not verify that you\n"
            + "are authorized to access the document\n"
            + "requested.  Either you supplied the wrong\n"
            + "credentials (e.g., bad password), or your\n"
            + "browser doesn't understand how to supply\n"
            + "the credentials required.</p>\n" + "</body></html>\n";
    DefaultFullHttpResponse response = responseFor(HttpVersion.HTTP_1_1,
            HttpResponseStatus.PROXY_AUTHENTICATION_REQUIRED, body);
    HttpHeaders.setDate(response, new Date());
    response.headers().set("Proxy-Authenticate",
            "Basic realm=\"" + (realm == null ? "Restricted Files" : realm) + "\"");
    write(response);
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:20,代码来源:ClientToProxyConnection.java

示例2: 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


注:本文中的io.netty.handler.codec.http.HttpHeaders.setDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。