本文整理匯總了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);
}
示例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 );
}
}
示例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");
}
}
示例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");
}
}