CXF WebClient overrides HTTP Content-Type
I'm trying to act as a proxy to a third party webservice, and need to transform a REST request. One issue that I have is that the Content-Type header seems to get overridden no matter what I do. The code is actually very simple (context is an @Context MessageContext variable):
WebClient client = WebClient.create(url)
.header("re开发者_JAVA技巧al-header-removed", "auth-string-removed")
//.header("Content-Type", context.getHttpHeaders().getMediaType().toString());
.type(context.getHttpHeaders().getMediaType());
Response resp = client.get();
return (InputStream)resp.getEntity();
Neither the .header nor the .type worked. The tcpmon output of the request is:
Content-Type: */*
real-header-removed: auth-string-removed
Accept: application/xml
User-Agent: Apache CXF 2.3.5
Cache-Control: no-cache
Pragma: no-cache
How do I avoid the Content-Type override (or rather, why is it happening?)
I needed to use client.invoke("GET", "");
精彩评论