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


Java ContainerResponse.setResponse方法代码示例

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


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

示例1: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest req,
		ContainerResponse contResp) {

	//String method = req.getMethod();
	
	ResponseBuilder resp = Response.fromResponse(contResp.getResponse());
	
	resp.header("Access-Control-Allow-Origin", "*");
	resp.header("Access-Control-Allow-Headers", "origin, content-type, accept, authorization, x-requested-with");
	resp.header("Access-Control-Allow-Credentials", "true");
	resp.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD");
	resp.header("Access-Control-Max-Age", "1209600");

	contResp.setResponse(resp.build());
	return contResp;
}
 
开发者ID:GLORIA-project,项目名称:gloria-core,代码行数:18,代码来源:ResponseCorsFilter.java

示例2: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest req,
		ContainerResponse contResp) {

	ResponseBuilder resp = Response.fromResponse(contResp.getResponse());
	resp.header("Access-Control-Allow-Origin", "*").header(
			"Access-Control-Allow-Methods", "GET, POST, OPTIONS");

	String reqHead = req.getHeaderValue("Access-Control-Request-Headers");

	if (null != reqHead && !reqHead.equals(null)) {
		resp.header("Access-Control-Allow-Headers", reqHead);
	}

	contResp.setResponse(resp.build());
	return contResp;
}
 
开发者ID:srdc,项目名称:semanticMDR,代码行数:18,代码来源:ResponseCorsFilter.java

示例3: addRequestIdToResponse

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
/**
 * Private helper that adds the request-id to the response payload.
 * @param response
 */
private void addRequestIdToResponse(ContainerResponse response) {
	
	// The request-id to be injected in the response
	String requestId = StaashRequestContext.getRequestId();
	
	// The key response attributes
	int status = response.getStatus();
	MediaType mediaType = response.getMediaType();
	
	if (mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
		
		String message = (String)response.getEntity();
		JsonObject json = new JsonObject(message);
		json.putString("request-id", requestId);
		
		Response newJerseyResponse = Response.status(status).type(mediaType).entity(json.toString()).build();
		response.setResponse(newJerseyResponse);
	}
		
	// Add the request id to the response regardless of the media type, 
	// this allows non json responses to have a request id in the response
	response.getHttpHeaders().add("x-nflx-staash-request-id", requestId);
}
 
开发者ID:Netflix,项目名称:staash,代码行数:28,代码来源:StaashAuditFilter.java

示例4: 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

示例5: filter

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

	ResponseBuilder responseBuilder = Response.fromResponse(response
			.getResponse());
	responseBuilder.header("Access-Control-Allow-Origin", "*").header(
			"Access-Control-Allow-Methods",
			"GET, POST, PUT, DELETE, OPTIONS");

	String requestHead = request
			.getHeaderValue("Access-Control-Request-Headers");

	if (null != requestHead && !requestHead.equals(null)) {
		responseBuilder.header("Access-Control-Allow-Headers", requestHead);
	}

	response.setResponse(responseBuilder.build());
	return response;
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:21,代码来源:CrossOriginResourceSharingFilter.java

示例6: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest req, ContainerResponse contResp) {
 
    ResponseBuilder resp = Response.fromResponse(contResp.getResponse());
    resp.header("Access-Control-Allow-Origin", "*")
        .header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
 
    String reqHead = req.getHeaderValue("Access-Control-Request-Headers");
 
    if(null != reqHead && !reqHead.equals("")){
        resp.header("Access-Control-Allow-Headers", reqHead);
    }
 
    contResp.setResponse(resp.build());
    return contResp;
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:17,代码来源:ResponseCorsFilter.java

示例7: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(final ContainerRequest req, final ContainerResponse cres) {
    Response.ResponseBuilder resp = Response.fromResponse(cres.getResponse());
    resp.header("Access-Control-Allow-Origin", "*")
            .header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");

    String reqHead = req.getHeaderValue("Access-Control-Request-Headers");
    System.out.println("Head:" + reqHead);
    if(null != reqHead && !reqHead.equals("")){
        resp.header("Access-Control-Allow-Headers", reqHead);
    }

    cres.setResponse(resp.build());
    return cres;
}
 
开发者ID:btrplace,项目名称:playd,代码行数:16,代码来源:CORSFilter.java

示例8: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter( ContainerRequest req, ContainerResponse contResp ) {

	ResponseBuilder resp = Response.fromResponse( contResp.getResponse());
	Map<String,String> headers = buildHeaders(
			req.getHeaderValue( CORS_REQ_HEADERS ),
			req.getHeaderValue( ORIGIN ));

	for( Map.Entry<String,String> h : headers.entrySet())
		resp.header( h.getKey(), h.getValue());

	contResp.setResponse( resp.build());
	return contResp;
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:15,代码来源:ResponseCorsFilter.java


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