How to dump HTTP body and headers sent with HTTP component with Apache Camel(如何使用 Apache Camel 转储与 HTTP 组件一起发送的 HTTP 正文和标头)
问题描述
如何使用此路由转储 Apache Camel HTTP 组件发送的 HTTP 正文和标头:
How to dump HTTP body and headers sent with Apache Camel HTTP component using this route:
from('direct:abc').
setHeader(Exchange.HTTP_URI, constant("${config.gnutch.solr.coreUrl}/select")).
setHeader(Exchange.HTTP_QUERY, constant("q=${q}&wt=xml")).
setHeader(Exchange.CONTENT_TYPE, constant('application/xml')).
setHeader(Exchange.HTTP_METHOD, constant('GET')).
setBody(constant(null)).
to("http://null")
这是 groovy 中的 Camel DSL 代码.这可能吗?
This is Camel DSL code in groovy. Is that possible?
推荐答案
你有没有尝试过类似的方法
Have you tried something like
from("direct:abc")
.to("http://domain.com/")
.to("log:DEBUG?showBody=true&showHeaders=true")
HTTP 组件文档 建议您可以提取 HttpServletRequest 来自交流之类的,
Also the HTTP Component Documentation suggests that you can extract the HttpServletRequest from the exchange like,
HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
你也可以这样做,
from("direct:abc").to("http://domain.com").process(new Processor() {
public void process(Exchange exchange) throws Exception {
HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
// Log request parameters
}
});
这篇关于如何使用 Apache Camel 转储与 HTTP 组件一起发送的 HTTP 正文和标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 Apache Camel 转储与 HTTP 组件一起发送的 HTTP 正文和标头
基础教程推荐
- Struts2 URL 无法访问 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
