问题
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