如何设置骆驼http4端点的HTTP头 [英] How to set HTTP headers on Camel http4 endpoint

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

问题描述

即如何设置一个请求头使用骆驼的http4成分制成?我连接到网站需要网址标头进行设置。直接使用HttpClient的,可以头添加到请求,但我看不出如何在骆驼的暴露出来。

埃塔:基于公认的答案的例子:

 从(计时器:// foo的固定利率=真放;延迟= 0&安培;周期= 300000)
      .setHeader(引荐,定(https://example.com))
      。要(https4://www.example.com中)


解决方案

您应该只可以将其设置为在骆驼路由头(如果使用)

 的setHeader(引荐,定(myvalue的))

虽然你的问题是有点太模糊,你如何使用骆驼http4组件发送请求。

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: 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")

解决方案

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

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

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

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

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