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


Java HttpServletResponse.containsHeader方法代码示例

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


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

示例1: onAuthenticationSuccess

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void onAuthenticationSuccess(
    HttpServletRequest request, HttpServletResponse response, Authentication authentication)
    throws IOException {

  if (response.containsHeader(X_SET_AUTHORIZATION_BEARER_HEADER)) {
    LOGGER.debug("{} has already been set.", X_SET_AUTHORIZATION_BEARER_HEADER);
    return;
  }

  String jwtToken = jwtTokenService.createJwtToken(authentication, ONE_DAY_MINUTES);
  response.setHeader(X_SET_AUTHORIZATION_BEARER_HEADER, jwtToken);
}
 
开发者ID:springuni,项目名称:springuni-particles,代码行数:14,代码来源:DefaultAuthenticationSuccessHandler.java

示例2: filterClickJack

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 跨域攻击处理
 *
 * @param response
 */
private void filterClickJack ( HttpServletResponse response ) {
    if ( ! response.containsHeader( X_FRAME_HEADER ) ) {
        /** 使用 X-Frame-Options 防止被iframe 造成跨域iframe 提交挂掉 **/
        response.addHeader( X_FRAME_HEADER , X_FRAME_VALUE );
    }
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:12,代码来源:InjectionAttackFilter.java

示例3: addCommonResponseHeaders

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private static void addCommonResponseHeaders(final HttpServletResponse response) {
    if (!response.containsHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS)) {
        response.addHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff");
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:6,代码来源:AbstractHttpMethodsFilter.java

示例4: addGzipHeader

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Adds the gzip HTTP header to the response.
 * <p/>
 * <p>
 * This is need when a gzipped body is returned so that browsers can properly decompress it.
 * </p>
 *
 * @param response the response which will have a header added to it. I.e this method changes its parameter
 * @throws GzipResponseHeadersNotModifiableException Either the response is committed or we were called using the include method
 *                                                   from a {@link javax.servlet.RequestDispatcher#include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)}
 *                                                   method and the set header is ignored.
 */
public static void addGzipHeader(HttpServletResponse response) throws GzipResponseHeadersNotModifiableException {
    response.setHeader("Content-Encoding", "gzip");
    boolean containsEncoding = response.containsHeader("Content-Encoding");
    if (!containsEncoding) {
        throw new GzipResponseHeadersNotModifiableException("Failure when attempting to set "
                + "Content-Encoding: gzip");
    }
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:21,代码来源:GZipResponseUtil.java


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