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 正文和标头
基础教程推荐
- 将 Windows 证书导入 Java 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
