【发布时间】:2013-06-10 13:59:05
【问题描述】:
在 Apache Camel 项目中使用 Restlet component,我无法在 onException 的响应中设置 HTTP 状态代码。
考虑一个配置如下的骆驼RouteBuilder:
onException(Exception.class)
.handled(true)
.process(new FailureResponseProcessor());
from("restlet:http://example.com/foo")
.process(fooProcessor)
.to("file:data/outbox");
在FailureResponseProcessor我尝试设置Restlet的HTTP响应码:
public void process(Exchange exchange) throws Exception {
Response response = exchange.getIn()
.getHeader(RestletConstants.RESTLET_RESPONSE,
Response.class);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
}
这不起作用。 HTTP 响应的状态始终为200 OK。
什么是有效设置 HTTP 状态码的必要条件?
【问题讨论】:
标签: exception apache-camel restlet http-status-codes