jeudi 26 février 2015

How do I add a header to a CXF WebClient request?



I want to do the equivalent of this curl command:



curl --header "Access-Control-Request-Headers: foo, bar" url


The CXF API gives the impression that this is straight forward, but I can't get it to work. Here's my code:



List<Object> providers = new ArrayList<>();
providers.add(new JacksonJaxbJsonProvider());
WebClient client = WebClient.create("http://localhost:8080/app/v2/preview", providers).accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON);
Response response = client.header("Access-Control-Request-Headers", "foo, bar").get();


The difference is, if I hit a breakpoint on my server, the curl command has this header, and the WebClient command doesn't. Is this a bug? If not, what am I doing wrong?


I'm using the cxf-bundle-minimal-2.7.10 version of the web client.




Aucun commentaire:

Enregistrer un commentaire