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


Java ContainerResponse.getHttpHeaders方法代码示例

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


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

示例1: addResponseHeaders

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
/**
 * 全てのレスポンスに共通するレスポンスヘッダーを追加する.
 * Access-Control-Allow-Origin, Access-Control-Allow-Headers<br/>
 * X-Personium-Version<br/>
 * @param request
 * @param response
 */
private void addResponseHeaders(final ContainerRequest request, final ContainerResponse response) {
    MultivaluedMap<String, Object> mm = response.getHttpHeaders();
    String acrh = request.getHeaderValue(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS);
    if (acrh != null) {
        mm.putSingle(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, acrh);
    } else {
        mm.remove(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS);
    }
    mm.putSingle(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, HttpHeaders.Value.ASTERISK);
    // X-Personium-Version
    mm.putSingle(HttpHeaders.X_PERSONIUM_VERSION, PersoniumUnitConfig.getCoreVersion());
}
 
开发者ID:personium,项目名称:personium-core,代码行数:20,代码来源:PersoniumCoreContainerFilter.java

示例2: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response)
{
	if (!isCorsNeeded(request))
		return response;

	MultivaluedMap<String, Object> headers = response.getHttpHeaders();

	headers.add("Access-Control-Allow-Origin", "*");
	headers.add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");

	String acrh = request.getHeaderValue("Access-Control-Request-Headers");
	if (acrh != null && !acrh.isEmpty())
		headers.add("Access-Control-Allow-Headers", acrh);

	return response;
}
 
开发者ID:zach-m,项目名称:gae-jersey-guice-jsf,代码行数:18,代码来源:CorsFilter.java

示例3: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
    String incomingOrigin = request.getHeaderValue(CorsHeaders.ORIGIN);
    if (incomingOrigin == null) {
        return response;
    }

    MultivaluedMap<String, Object> h = response.getHttpHeaders();
    putIfNotPresent(h, CorsHeaders.ALLOW_ORIGIN, allowOrigin);
    putIfNotPresent(h, CorsHeaders.MAX_AGE, Integer.toString(maxAge));
    if (!allowMethods.isEmpty()) {
        putIfNotPresent(h, CorsHeaders.ALLOW_METHODS, allowMethods);
    }
    if (!allowHeaders.isEmpty()) {
        putIfNotPresent(h, CorsHeaders.ALLOW_HEADERS, allowHeaders);
    }
    if (allowCredentials) {
        putIfNotPresent(h, CorsHeaders.ALLOW_CREDENTIALS, Boolean.toString(allowCredentials));
    }
    return response;
}
 
开发者ID:palominolabs,项目名称:jersey-cors-filter,代码行数:22,代码来源:CorsPreflightResponseResourceFilter.java

示例4: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
    String incomingOrigin = request.getHeaderValue(CorsHeaders.ORIGIN);
    if (incomingOrigin == null) {
        return response;
    }

    MultivaluedMap<String, Object> h = response.getHttpHeaders();
    putIfNotPresent(h, CorsHeaders.ALLOW_ORIGIN, allowOrigin);
    if (!exposeHeaders.isEmpty()) {
        putIfNotPresent(h, CorsHeaders.EXPOSE_HEADERS, exposeHeaders);
    }
    if (allowCredentials) {
        putIfNotPresent(h, CorsHeaders.ALLOW_CREDENTIALS, Boolean.toString(allowCredentials));
    }
    return response;
}
 
开发者ID:palominolabs,项目名称:jersey-cors-filter,代码行数:18,代码来源:CorsResourceResponseResourceFilter.java

示例5: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request,
                                ContainerResponse response) {
    Object entity = response.getEntity();
    if (entity instanceof BaseEntity) {
        Date lastModified = getLastModificationTime((BaseEntity) entity);
        if (lastModified != null) {

            ResponseBuilder b = request.evaluatePreconditions(lastModified);
            if (b != null) {
                response.setResponse(b.build());
            } else {
                MultivaluedMap<String, Object> headers = response.getHttpHeaders();
                headers.putSingle(HttpHeaders.LAST_MODIFIED, lastModified);
            }
        }
    }
    return response;
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:20,代码来源:CachingFilter.java

示例6: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
  if (request.getMethod().equalsIgnoreCase("GET") == false) {
    return response;
  }
  MultivaluedMap<String, Object> headers = response.getHttpHeaders();
  if (headers.containsKey(HttpHeaders.ETAG) == false &&
      headers.containsKey(HttpHeaders.CACHE_CONTROL) == false &&
      headers.containsKey(HttpHeaders.EXPIRES) == false) {
    headers.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, max-age=0, must-revalidate");
    headers.add(HttpHeaders.EXPIRES, "Mon, 26 Jul 1997 05:00:00 GMT");
  }
  return response;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:15,代码来源:NoCachingFilter.java

示例7: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
    MultivaluedMap<String, Object> headers = response.getHttpHeaders();
    Object first = headers.getFirst(HttpHeaders.CONTENT_TYPE);
    String contentType = first == null
        ? String.format("%s; charset=utf-8", MediaType.APPLICATION_JSON)
        : String.format("%s; charset=utf-8", first.toString());
    headers.putSingle(HttpHeaders.CONTENT_TYPE, contentType);
    return response;
}
 
开发者ID:Unisay,项目名称:preferanser,代码行数:10,代码来源:EncodingJerseyResponseFilter.java

示例8: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
	MultivaluedMap<String, Object> httpHeaders = response.getHttpHeaders();
	httpHeaders.putSingle("Pragma", "no-cache");
	httpHeaders.putSingle("Cache-Control", "no-cache, must-revalidate");
	return response;
}
 
开发者ID:HuygensING,项目名称:elaborate4-backend,代码行数:8,代码来源:CacheHeaderFilter.java

示例9: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest containerRequest, ContainerResponse containerResponse) {
    if (null == containerResponse.getEntity())
        return containerResponse;
    if (!containerResponse.getEntity().getClass().isAnnotationPresent(XmlRootElement.class))
        return containerResponse;
    XmlRootElement annotation = containerResponse.getEntity().getClass().getAnnotation(XmlRootElement.class);
    String name = annotation.name();
    if (null == name || name.equals("##default"))
        return containerResponse;

    StringWriter sw = new StringWriter();
    try {
        JAXBContext c = getJAXBContext(containerResponse.getEntity().getClass());
        Marshaller marshaller = c.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
        marshaller.marshal(containerResponse.getEntity(), sw);
        String xml = sw.toString();
        xml = xml.replace(String.format("<%s>", name), String.format("<%s xmlns=\"http://doc.s3.amazonaws.com/2006-03-01\">", name));
        // DL: removed this log line, as it was spewing very large messages when user has several buckets
        // LOG.debug(xml);
        containerResponse.setEntity(xml);
        LOG.debug("http headers: " + containerResponse.getHttpHeaders());
        // set the content-length otherwise the server seems to set the Content-Encoding to chunked which some
        // clients don't like
        MultivaluedMap<String, Object> requestHeaders = containerResponse.getHttpHeaders();

        requestHeaders.remove(HttpHeaders.CONTENT_LENGTH);
        requestHeaders.add(HttpHeaders.CONTENT_LENGTH, xml.length());
    } catch (JAXBException e) {
        LOG.error("error formatting xml", e);
        ResponseBuilder responseBuilder = Response.serverError();
        responseBuilder.entity(e.getMessage());
        throw new WebApplicationException(responseBuilder.build());
    }
    return containerResponse;
}
 
开发者ID:barnyard,项目名称:pi,代码行数:38,代码来源:NamespaceManglingFilter.java

示例10: writeStatusAndHeaders

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public OutputStream writeStatusAndHeaders(long contentLength,
                                          ContainerResponse response)
        throws IOException {
    this.mediaType = response.getMediaType();
    this.crwout = crw.writeStatusAndHeaders(contentLength, response);
    this.baos = new ByteArrayOutputStream();
    this.httpHeaders = response.getHttpHeaders();
    return this.baos;
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:11,代码来源:JSONSchemaResourceFilterFactory.java


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