org.eclipse.jetty.client.api.Request.accept()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中org.eclipse.jetty.client.api.Request.accept方法的一些代码示例,展示了Request.accept的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.accept方法的具体详情如下:
包路径:org.eclipse.jetty.client.api.Request
类名称:Request
方法名:accept

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;
}

相关文章