2

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 = org.apache.cxf.jaxrs.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 request 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.

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356

0 Answers0