本文整理了Java中org.apache.cxf.jaxrs.client.WebClient.getHeaders()
方法的一些代码示例,展示了WebClient.getHeaders()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.getHeaders()
方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.client.WebClient
类名称:WebClient
方法名:getHeaders
暂无
代码示例来源:origin: apache/cxf
private MultivaluedMap<String, String> prepareHeaders(Class<?> responseClass, Object body) {
MultivaluedMap<String, String> headers = getHeaders();
if (headers.getFirst(HttpHeaders.CONTENT_TYPE) == null && body instanceof Form) {
headers.putSingle(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED);
}
if (responseClass != null && responseClass != Response.class
&& headers.getFirst(HttpHeaders.ACCEPT) == null) {
headers.putSingle(HttpHeaders.ACCEPT, MediaType.WILDCARD);
}
return headers;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client
private MultivaluedMap<String, String> prepareHeaders(Class<?> responseClass, Object body) {
MultivaluedMap<String, String> headers = getHeaders();
if (headers.getFirst(HttpHeaders.CONTENT_TYPE) == null && body instanceof Form) {
headers.putSingle(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED);
}
if (responseClass != null && responseClass != Response.class
&& headers.getFirst(HttpHeaders.ACCEPT) == null) {
headers.putSingle(HttpHeaders.ACCEPT, MediaType.WILDCARD);
}
return headers;
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
private MultivaluedMap<String, String> prepareHeaders(Class<?> responseClass, Object body) {
MultivaluedMap<String, String> headers = getHeaders();
if (body != null && headers.getFirst(HttpHeaders.CONTENT_TYPE) == null) {
String ct = body instanceof Form ? MediaType.APPLICATION_FORM_URLENCODED
: MediaType.APPLICATION_XML;
headers.putSingle(HttpHeaders.CONTENT_TYPE, ct);
}
if (responseClass != null && responseClass != Response.class
&& headers.getFirst(HttpHeaders.ACCEPT) == null) {
headers.putSingle(HttpHeaders.ACCEPT, JAXRSUtils.mediaTypeToString(MediaType.APPLICATION_XML_TYPE));
}
return headers;
}
代码示例来源:origin: org.apache.camel/camel-cxf
&& ObjectHelper.isNotEmpty(client.getHeaders().get(Exchange.CONTENT_TYPE))) {
inMessage.setHeader(Exchange.CONTENT_TYPE, client.getHeaders().get(Exchange.CONTENT_TYPE).get(0));
代码示例来源:origin: apache/cxf
@Test
public void testNoResultsAreReturned() throws Exception {
WebClient client = WebClient.create("http://localhost:" + PORT + "/resource/jaxb");
WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(3000000);
List<String> values = new ArrayList<>();
values.add(MediaType.APPLICATION_XML);
client.getHeaders().put("content-type", values);
JAXBElement<String> test = new JAXBElement<>(new QName("org.apache.cxf", "jaxbelement"),
String.class, "test");
Response response = client.post(test);
String result = response.readEntity(String.class);
assertTrue(result.contains("<jaxbelement xmlns=\"org.apache.cxf\">test</jaxbelement>"));
Assert.assertFalse(result.contains("WriteInCXFJaxbProvider"));
}
}
代码示例来源:origin: apache/cxf
private void invoke(int ind) throws Exception {
client.type("text/plain").accept("text/plain");
String actualHeaderName = bookHeader + ind;
String actualBookName = bookName + ind;
MultivaluedMap<String, String> map = client.getHeaders();
map.putSingle("CustomHeader", actualHeaderName);
client.headers(map).path("booksecho");
doInvoke(actualBookName, actualHeaderName);
// reset current path
client.back(true);
}
内容来源于网络,如有侵权,请联系作者删除!