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


Java ContainerResponseContext.getHeaders方法代码示例

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


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

示例1: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(
           ContainerRequestContext containerRequestContext,
           ContainerResponseContext containerResponseContext) throws IOException {

	MultivaluedMap<String, Object> headers = containerResponseContext.getHeaders();

	headers.add(
               "Access-Control-Allow-Origin",
               "*");
       headers.add(
               "Access-Control-Allow-Methods",
               "GET, POST, OPTIONS");
       headers.add(
               "Access-Control-Allow-Headers",
               "Cache-Control, X-Requested-With, Origin, Content-Type, Accept, Authorization");
   }
 
开发者ID:Lambda-3,项目名称:Graphene,代码行数:18,代码来源:CORSFilter.java

示例2: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext containerRequestContext,
		ContainerResponseContext containerResponseContext) throws IOException {

	MultivaluedMap<String, Object> headers = containerResponseContext.getHeaders();
	headers.add(ACCESS_CONTROL_ALLOW_HEADERS, "orgin");
	headers.add(ACCESS_CONTROL_ALLOW_HEADERS, "content-type");
	headers.add(ACCESS_CONTROL_ALLOW_HEADERS, "accept");
	headers.add(ACCESS_CONTROL_ALLOW_HEADERS, "authorization");

	customHeaders.forEach(s -> headers.add(ACCESS_CONTROL_ALLOW_HEADERS, s));

	// make sure there's only one header with this name
	String headerString = (String) headers.get(ACCESS_CONTROL_ALLOW_HEADERS).stream()
			.reduce((a, b) -> a.toString() + ", " + b.toString()).get();
	headers.putSingle(ACCESS_CONTROL_ALLOW_HEADERS, headerString);

	headers.putSingle("Access-Control-Allow-Credentials", "true");
	headers.putSingle("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
}
 
开发者ID:Mercateo,项目名称:rest-jersey-utils,代码行数:21,代码来源:SimpleAccessControlAllowHeaderFilter.java

示例3: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
        throws IOException {
    RequestLog.startTiming(this);
    MultivaluedMap<String, Object> headers = responseContext.getHeaders();

    String origin = requestContext.getHeaderString("origin");
    if (origin == null || "".equals(origin)) {
        headers.add("Access-Control-Allow-Origin", "*");
    } else {
        headers.add("Access-Control-Allow-Origin", origin);
    }

    String requestedHeaders = requestContext.getHeaderString("access-control-request-headers");
    // allow all requested headers
    headers.add("Access-Control-Allow-Headers", requestedHeaders == null ? "" : requestedHeaders);

    headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS, PUT, PATCH");
    headers.add("Access-Control-Allow-Credentials", "true");
    RequestLog.stopTiming(this);
}
 
开发者ID:yahoo,项目名称:fili,代码行数:22,代码来源:ResponseCorsFilter.java

示例4: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext,
        ContainerResponseContext responseContext) throws IOException {

    MultivaluedMap<String, Object> headers = responseContext.getHeaders();

    //生成元が異なる場合frame要素やiframe要素の内部に表示しない
    headers.add("X-Frame-Options", "SAMEORIGIN");

    //Content-Typeの自動判別防止
    headers.add("X-Content-Type-Options", "nosniff");

    //XSSフィルターを有効化する
    headers.add("X-XSS-Protection", "1; mode=block");

    //リソースの取得元を生成元のみに制限する
    //画像は生成元に加えてgravatarも許可する
    headers.add("Content-Security-Policy",
            "default-src 'self'; img-src 'self' www.gravatar.com");
}
 
开发者ID:backpaper0,项目名称:sealion,代码行数:21,代码来源:SecurityResponseHeaders.java

示例5: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
   public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
    throws IOException {
MultivaluedMap<String, Object> headers = responseContext.getHeaders();
// Allow from all origins...
if (!headers.containsKey("Access-Control-Allow-Origin")) {
    headers.add("Access-Control-Allow-Origin", "*");
}
// Allow changing the following headers...
if (!headers.containsKey("Access-Control-Allow-Headers")) {
    headers.add("Access-Control-Allow-Headers", "Content-Type, auth-id, auth-token");
}
// Allow credentials...
if (!headers.containsKey("Access-Control-Allow-Credentials")) {
    headers.add("Access-Control-Allow-Credentials", "true");
}
// Allow methods...
if (!headers.containsKey("Access-Control-Allow-Methods")) {
    headers.add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD");
}
// Max 14 days...
if (!headers.containsKey("Access-Control-Max-Age")) {
    headers.add("Access-Control-Max-Age", "1209600");
}
   }
 
开发者ID:PureSolTechnologies,项目名称:Purifinity,代码行数:26,代码来源:CORSFilter.java

示例6: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
		throws IOException {

	MultivaluedMap<String, Object> headers = responseContext.getHeaders();

	headers.add("Access-Control-Allow-Origin", "*");
	headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");			
	headers.add("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, X-Codingpedia");
}
 
开发者ID:jiumao-org,项目名称:wechat-mall,代码行数:10,代码来源:CORSResponseFilter.java

示例7: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException {
  MultivaluedMap<String, Object> headers = containerResponseContext.getHeaders();

  headers.add("Access-Control-Allow-Origin", containerRequestContext.getHeaders().getFirst("Origin"));
  headers.add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization");
  headers.add("Access-Control-Allow-Credentials", "true");
  headers.add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD");
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:10,代码来源:InCORSFilter.java

示例8: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
        throws IOException
{
    MultivaluedMap<String, Object> headers = responseContext.getHeaders();
    headers.add(ALLOW_ORIGIN, requestContext.getHeaderString(ORIGIN));
    headers.add(ALLOW_METHODS, requestContext.getHeaderString(REQUEST_METHOD));
    headers.add(ALLOW_HEADERS, requestContext.getHeaderString(REQUEST_HEADERS));
    headers.add(ALLOW_CREDENTIALS, true);
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:11,代码来源:ResponseCorsFilter.java

示例9: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext req, ContainerResponseContext res) throws IOException {
    MultivaluedMap<String, Object> headers = res.getHeaders();
    headers.add("Access-Control-Allow-Origin", "*");
    headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS, HEAD");
    headers.add("Access-Control-Allow-Headers", "Content-Type"); // X-Requested-With を追加するべき?
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:8,代码来源:CORSResponseFilter.java

示例10: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(
		ContainerRequestContext containerRequestContext,
		ContainerResponseContext containerResponseContext)
	throws IOException {

	Object entity = containerResponseContext.getEntity();

	if (entity instanceof Try.Failure) {
		Try.Failure failure = (Try.Failure)entity;

		Exception exception = failure.getException();

		Optional<APIError> optional = _exceptionConverterManager.convert(
			exception);

		APIError apiError = optional.orElseThrow(
			() -> new MustHaveExceptionConverter(exception.getClass()));

		if (_apioLogger != null) {
			_apioLogger.error(apiError);
		}

		ErrorMessageMapper errorMessageMapper =
			_errorMessageMapperManager.getErrorMessageMapper(
				apiError, _httpHeaders);

		String result = ErrorWriter.writeError(
			errorMessageMapper, apiError, _httpHeaders);

		MultivaluedMap<String, Object> headers =
			containerResponseContext.getHeaders();

		headers.remove("Content-Type");
		headers.add("Content-Type", errorMessageMapper.getMediaType());

		containerResponseContext.setEntity(result);
		containerResponseContext.setStatus(apiError.getStatusCode());
	}
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:41,代码来源:FailureFilter.java

示例11: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
    throws IOException {

    MultivaluedMap<String, Object> headers = responseContext.getHeaders();

    headers.add("Access-Control-Allow-Origin", "*");
    headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS");
    headers.add("Access-Control-Allow-Headers", "X-Requested-With, Content-Type");
}
 
开发者ID:groovylabs,项目名称:lyre,代码行数:10,代码来源:CORSFilter.java

示例12: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
    final MultivaluedMap<String, Object> headers = responseContext.getHeaders();
    headers.add("Access-Control-Allow-Origin", "*");
    headers.add("Access-Control-Allow-Headers", getRequestedAllowedHeaders(requestContext));
    // do not set expose headers
    //headers.add("Access-Control-Expose-Headers", getRequestedExposedHeaders(requestContext));
    headers.add("Access-Control-Allow-Credentials", "true");
    headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS);
    headers.add("Access-Control-Max-Age", MAX_AGE);
    headers.add("x-responded-by", "cors-response-filter");
}
 
开发者ID:hantsy,项目名称:javaee8-jaxrs-sample,代码行数:13,代码来源:CorsResponseFilter.java

示例13: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext cres)
		throws IOException {
	MultivaluedMap<String, Object> headers = cres.getHeaders();

	headers.add("Access-Control-Allow-Origin", "*");
	headers.add("Access-Control-Allow-Headers", "origin, content-converter, accept, authorization");
	headers.add("Access-Control-Allow-Credentials", "true");
	headers.add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD");
	headers.add("Access-Control-Max-Age", "1209600");
}
 
开发者ID:pwalser75,项目名称:jee-demo,代码行数:12,代码来源:CORSFilter.java

示例14: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext responseContext)
		throws IOException {

	final MultivaluedMap<String, Object> headers = responseContext.getHeaders();

	headers.add("Access-Control-Allow-Origin", "*");
	headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, PATCH");
	headers.add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
}
 
开发者ID:ExplorViz,项目名称:explorviz-backend,代码行数:11,代码来源:CORSResponseFilter.java

示例15: filter

import javax.ws.rs.container.ContainerResponseContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
        throws IOException {

    final MultivaluedMap<String, Object> headers = responseContext.getHeaders();
    // if
    // (requestContext.getHeaderString("Host").endsWith("pokebattler.com"))
    // {
    //
    // if (requestContext.getHeaderString("Origin") == null) {
    // headers.putSingle("Access-Control-Allow-Origin",
    // (requestContext.getSecurityContext().isSecure()?"https":"http") +
    // "://www.pokebattler.com");
    // } else if
    // (requestContext.getHeaderString("Origin").endsWith("pokebattler.com"))
    // {
    // headers.putSingle("Access-Control-Allow-Origin",
    // requestContext.getHeaderString("Origin"));
    // headers.putSingle("Access-Control-Allow-Origin", "*");
    // }
    // } else {
    headers.putSingle("Access-Control-Allow-Origin", "*");
    // }

    // headers.add("Access-Control-Allow-Origin",
    // "http://podcastpedia.org"); //allows CORS requests only coming from
    // podcastpedia.org
    headers.putSingle("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
    headers.putSingle("Access-Control-Allow-Headers", "X-Requested-With");
    headers.putSingle("Allow", "OPTIONS");
}
 
开发者ID:celandro,项目名称:pokebattler-fight,代码行数:32,代码来源:CORSResponseFilter.java


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