本文整理汇总了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");
}
}