當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。