如何在 Camel http4 端点上设置 HTTP 标头 [英] How to set HTTP headers on Camel http4 endpoint

查看:35
本文介绍了如何在 Camel http4 端点上设置 HTTP 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为使用 Camel 中的 http4 组件发出的请求设置标头?我要连接的站点需要设置引用标头.直接使用 HttpClient,可以向请求添加标头,但我看不到它在 Camel 中是如何公开的.

How does one set the headers for a request made using the http4 component in Camel? The site I'm connecting to requires the referrer header to be set. Using HttpClient directly, one can add headers to the request, but I can't see how that's exposed in Camel.

ETA:基于已接受答案的工作示例:

ETA: Working example based on the accepted answer:

 from("timer://foo?fixedRate=true&delay=0&period=300000")
      .setHeader("Referer", constant("https://example.com"))
      .to("https4://www.example.com")

推荐答案

您应该能够将其设置为 Camel 路由中的标题(如果您使用它)

You should just be able to set it as a header in the Camel route (if you use that)

setHeader("referrer", constant("MyValue"))

虽然您的问题有点过于模糊,您如何使用 Camel http4 组件发送请求.

Though your question is a bit too vague how you use Camel http4 component to send the request.

这篇关于如何在 Camel http4 端点上设置 HTTP 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆