apache-camel - 在 apache camel 中禁用自动重定向
问题描述
我试图在骆驼中禁用 HTTP 自动重定向,我在 SpringRouteBuilder 中实现了以下代码,问题是当我永久移动 HTTP/1.1 301 时,它会自动重定向。下面我添加了片段,请让我知道如何继续。
onException(HttpOperationFailedException.class).process(exchange -> {
final Exception t = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
if (t instanceof HttpOperationFailedException) {
LOGGER.error("HttpOperationFailedException Problem::::{}",
ToStringBuilder.reflectionToString(t, ToStringStyle.DEFAULT_STYLE));
}
});
from(SOURCE_URI).log(LoggingLevel.INFO, "[Service Route:][Request log:] ${body}").routeId(ROUTE_ID)
.setHeader(Exchange.HTTP_METHOD, Builder.constant("GET")).process(exchange -> {
exchange.getIn().setBody(EMPTY_REQUEST);
}).streamCaching().recipientList(header("PartnerUrl"));
}
在下面的文档中提到http://camel.apache.org/http4 响应代码在 300..399 范围内,Camel 将其视为重定向响应,并将抛出带有信息的 HttpOperationFailedException。我期待这个异常,但没有发生异常并被重定向。
解决方案
推荐阅读
- java - 为 JDBC 驱动程序设置 CLASSPATH 后无法找到或加载主类
- php - PHP 标准 DOMElement::setIdAttribute 错误
- excel - 用于填充的 Excel Office 脚本
- screenshot - 如何在带有状态栏和底部指示器的可编程 iPhone X 系列上截屏?
- android - Android TV - 以编程方式切换到 HDMI 输入
- c# - CsvHelper 流太长
- javascript - React - Material UI图标的propType应该是什么
- reactjs - 属性 'setUserName' 不存在 - 用测试库开玩笑测试
- c++ - 静态存储的字符串集
- c - 即使我在联合中使用指针,为什么联合的大小不是 8 个字节而是 4 个字节?