How to set HTTP headers on Camel http4 endpoint

百般思念 提交于 2020-01-15 09:10:23

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/17088722/how-to-set-http-headers-on-camel-http4-endpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!