本文整理了Java中org.eclipse.jetty.client.api.Request.accept
方法的一些代码示例,展示了Request.accept
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.accept
方法的具体详情如下:
包路径:org.eclipse.jetty.client.api.Request
类名称:Request
方法名:accept
暂无
代码示例来源:origin: embulk/embulk-output-elasticsearch
@Override
public void requestOnce(org.eclipse.jetty.client.HttpClient client, org.eclipse.jetty.client.api.Response.Listener responseListener)
{
org.eclipse.jetty.client.api.Request request = client
.newRequest(uri)
.accept("application/json")
.timeout(task.getTimeoutMills(), TimeUnit.MILLISECONDS)
.method(method);
if (method == HttpMethod.POST) {
request.content(new StringContentProvider(content), "application/json");
}
if (!authorizationHeader.isEmpty()) {
request.header("Authorization", authorizationHeader);
}
request.send(responseListener);
}
代码示例来源:origin: org.apache.kafka/connect-runtime
req.accept("application/json");
req.agent("kafka-connect");
if (serializedBody != null) {
代码示例来源:origin: org.infinispan/infinispan-server-rest
protected ContentResponse get(String cacheName, Object key, String acceptHeader) throws Exception {
Request request = client.newRequest(String.format("http://localhost:%d/rest/%s/%s", restServer().getPort(), cacheName, key))
.method(HttpMethod.GET);
if (acceptHeader != null) {
request.accept(acceptHeader);
}
ContentResponse response = request.send();
ResponseAssertion.assertThat(response).isOk();
return response;
}
代码示例来源:origin: org.infinispan/infinispan-server-rest
@Test
public void testWildcardAccept() throws Exception {
putStringValueInCache("default", "test", "test");
ContentResponse getResponse = client
.newRequest(String.format("http://localhost:%d/rest/%s/%s", restServer().getPort(), "default", "test"))
.accept("*/*")
.method(HttpMethod.GET)
.send();
ResponseAssertion.assertThat(getResponse).isOk();
ResponseAssertion.assertThat(getResponse).hasReturnedText("test");
}
代码示例来源:origin: org.infinispan/infinispan-server-rest
protected ContentResponse get(String cacheName, Object key, String keyContentType, String acceptHeader) throws Exception {
Request request = client.newRequest(String.format("http://localhost:%d/rest/%s/%s", restServer().getPort(), cacheName, key))
.method(HttpMethod.GET);
if (acceptHeader != null) {
request.accept(acceptHeader);
}
if (keyContentType != null) {
request.header("Key-Content-Type", keyContentType);
}
ContentResponse response = request.send();
ResponseAssertion.assertThat(response).isOk();
return response;
}
内容来源于网络,如有侵权,请联系作者删除!