org.eclipse.jetty.client.HttpClient.GET()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(270)

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

HttpClient.GET介绍

[英]Performs a GET request to the specified URI.
[中]对指定的URI执行GET请求。

代码示例

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

/**
 * Performs a GET request to the specified URI.
 *
 * @param uri the URI to GET
 * @return the {@link ContentResponse} for the request
 * @see #GET(URI)
 */
public ContentResponse GET(String uri) throws InterruptedException, ExecutionException, TimeoutException
{
  return GET(URI.create(uri));
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

/**
 * Performs a GET request to the specified URI.
 *
 * @param uri the URI to GET
 * @return the {@link ContentResponse} for the request
 * @see #GET(URI)
 */
public ContentResponse GET(String uri) throws InterruptedException, ExecutionException, TimeoutException
{
  return GET(URI.create(uri));
}

代码示例来源:origin: org.eclipse.jetty/jetty-client

/**
 * Performs a GET request to the specified URI.
 *
 * @param uri the URI to GET
 * @return the {@link ContentResponse} for the request
 * @throws InterruptedException if send threading has been interrupted
 * @throws ExecutionException the execution failed
 * @throws TimeoutException the send timed out
 * @see #GET(URI)
 */
public ContentResponse GET(String uri) throws InterruptedException, ExecutionException, TimeoutException
{
  return GET(URI.create(uri));
}

代码示例来源:origin: danielflower/app-runner

public static Waiter waitFor(String name, URI url, long timeout, TimeUnit unit) {
    return new Waiter(name, client -> {
      try {
        client.GET(url);
        return true;
      } catch (InterruptedException e) {
        return true; // erg... really want to bubble this but can't
      } catch (Exception ex) {
        return false;
      }
    }, timeout, unit);
  }
}

代码示例来源:origin: stackoverflow.com

SslContextFactory sslContextFactory = new SslContextFactory(true);
 HTTP2Client http2Client = new HTTP2Client();
 HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), sslContextFactory);
 httpClient.start();
 ContentResponse response = httpClient.GET("https://ec2-52-57-54-142.eu-central-1.compute.amazonaws.com/");

代码示例来源:origin: stackoverflow.com

// Setup and start HttpClient with HTTP/2 transport.
 HTTP2Client http2Client = new HTTP2Client();
 SslContextFactory sslContextFactory = new SslContextFactory();
 HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), sslContextFactory);
 httpClient.start();
 // Make a request.
 ContentResponse response = httpClient.GET("https://webtide.com/");

代码示例来源:origin: stackoverflow.com

// Setup.
HTTP2Client http2Client = new HTTP2Client();
SslContextFactory sslContextFactory = new SslContextFactory();
HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), sslContextFactory);
httpClient.start();

// Does webtide.com support HTTP/2 ?
ContentResponse response = httpClient.GET("https://webtide.com/");
// No errors, yes it supports HTTP/2 !

代码示例来源:origin: jpos/jPOS-EE

public static void main(String args[]) throws Exception {
  HttpClientSocketFactory f = HttpClientSocketFactory.getDefaultInstance();
  f.sslProviderClass = null;
  HttpClient c = f.getHttpClient(HttpType.HTTP);
  System.out.println(c.GET(args[0]).getContentAsString());
  c.stop();
}

代码示例来源:origin: org.infinispan/infinispan-server-rest

@Test
public void shouldGetNonExistingValue() throws Exception {
 //when
 ContentResponse response = client.GET("http://localhost:" + restServer().getPort() + "/rest/default/nonExisting");
 //then
 ResponseAssertion.assertThat(response).doesntExist();
}

代码示例来源:origin: org.infinispan/infinispan-server-rest

public void performGets(int pertentageOfMisses, int numberOfGets, String existingKey, String nonExistingKey) throws Exception {
 Random r = ThreadLocalRandom.current();
 for (int i = 0; i < numberOfGets; ++i) {
   String key = r.nextInt(100) < pertentageOfMisses ? nonExistingKey : existingKey;
   executorCompletionService.submit(() -> {
    if (http2) {
      FullHttpRequest getRequest = new DefaultFullHttpRequest(HTTP_1_1, GET, "/rest/default/" + key);
      nettyHttpClient.sendRequest(getRequest);
    } else {
      try {
       String scheme = usesTLS ? "https" : "http";
       http1Client
          .GET(String.format("%s://localhost:%d/rest/%s/%s", scheme, port, "default", key));
      } catch (Exception e) {
       throw new RuntimeException(e);
      }
    }
    return 1;
   });
 }
 for (int i = 0; i < numberOfGets; ++i) {
   executorCompletionService.take().get();
 }
 if (http2) {
   nettyHttpClient.getResponses();
 }
}

代码示例来源:origin: com.teradata.airlift/http-server

@Test
public void testIncludeCipherEmpty()
    throws Exception
{
  HttpServerConfig config = createHttpServerConfig()
      .setHttpsIncludedCipherSuites(" ,   ");
  NodeInfo nodeInfo = new NodeInfo("test");
  HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo);
  HttpServer server = createServer(nodeInfo, httpServerInfo, config);
  try {
    server.start();
    URI httpsUri = httpServerInfo.getHttpsUri();
    HttpClient httpClient = createClientIncludeCiphers(CIPHER_1);
    httpClient.GET(httpsUri);
    httpClient = createClientIncludeCiphers(CIPHER_2);
    httpClient.GET(httpsUri);
    httpClient = createClientIncludeCiphers(CIPHER_3);
    httpClient.GET(httpsUri);
  }
  finally {
    server.stop();
  }
}

代码示例来源:origin: com.teradata.airlift/http-server

httpClient.GET(httpsUri);
httpClient.GET(httpsUri);
  httpClient.GET(httpsUri);
  Assert.fail("SSL handshake should fail because client included only ciphers the server didn't include");

代码示例来源:origin: io.airlift/http-server

@Test
public void testIncludeCipherEmpty()
    throws Exception
{
  HttpServerConfig config = createHttpServerConfig()
      .setHttpsExcludedCipherSuites("")
      .setHttpsIncludedCipherSuites(" ,   ");
  NodeInfo nodeInfo = new NodeInfo("test");
  HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo);
  HttpServer server = createServer(nodeInfo, httpServerInfo, config);
  try {
    server.start();
    URI httpsUri = httpServerInfo.getHttpsUri();
    HttpClient httpClient = createClientIncludeCiphers(CIPHER_1);
    httpClient.GET(httpsUri);
    httpClient = createClientIncludeCiphers(CIPHER_2);
    httpClient.GET(httpsUri);
    httpClient = createClientIncludeCiphers(CIPHER_3);
    httpClient.GET(httpsUri);
  }
  finally {
    server.stop();
  }
}

代码示例来源:origin: io.airlift/http-server

httpClient.GET(httpsUri);
httpClient.GET(httpsUri);
  httpClient.GET(httpsUri);
  fail("SSL handshake should fail because client included only ciphers the server didn't include");

代码示例来源:origin: com.teradata.airlift/http-server

@Test
public void testExcludedCipher()
    throws Exception
{
  HttpServerConfig config = createHttpServerConfig()
      .setHttpsExcludedCipherSuites(CIPHER_1 + "," + CIPHER_2);
  NodeInfo nodeInfo = new NodeInfo("test");
  HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo);
  HttpServer server = createServer(nodeInfo, httpServerInfo, config);
  try {
    server.start();
    URI httpsUri = httpServerInfo.getHttpsUri();
    // should succeed because all ciphers accepted
    HttpClient httpClient = createClientIncludeCiphers();
    httpClient.GET(httpsUri);
    httpClient = createClientIncludeCiphers(CIPHER_1, CIPHER_2);
    try {
      httpClient.GET(httpsUri);
      Assert.fail("SSL handshake should fail because client included only ciphers the server excluded");
    }
    catch (ExecutionException e) {
      // expected
    }
  }
  finally {
    server.stop();
  }
}

代码示例来源:origin: io.airlift/http-server

@Test
public void testExcludedCipher()
    throws Exception
{
  HttpServerConfig config = createHttpServerConfig()
      .setHttpsExcludedCipherSuites(CIPHER_1 + "," + CIPHER_2);
  NodeInfo nodeInfo = new NodeInfo("test");
  HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo);
  HttpServer server = createServer(nodeInfo, httpServerInfo, config);
  try {
    server.start();
    URI httpsUri = httpServerInfo.getHttpsUri();
    // should succeed because all ciphers accepted
    HttpClient httpClient = createClientIncludeCiphers();
    httpClient.GET(httpsUri);
    httpClient = createClientIncludeCiphers(CIPHER_1, CIPHER_2);
    try {
      httpClient.GET(httpsUri);
      fail("SSL handshake should fail because client included only ciphers the server excluded");
    }
    catch (ExecutionException e) {
      // expected
    }
  }
  finally {
    server.stop();
  }
}

代码示例来源:origin: org.eclipse.jetty.tests/test-sessions-common

ContentResponse response1 = client.GET(url + "?action=init");
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");

代码示例来源:origin: org.eclipse.jetty.tests/test-sessions-common

ContentResponse response = client.GET("http://localhost:" + port + "/mod/test?action=create");

代码示例来源:origin: org.eclipse.jetty.tests/test-sessions-common

ContentResponse response = client.GET("http://localhost:" + port + "/mod/test?action=create");

代码示例来源:origin: org.eclipse.jetty.tests/test-sessions-common

ContentResponse response = client.GET("http://localhost:" + port + "/mod/test?action=create");

相关文章

HttpClient类方法