Tabnine Logo
HttpClientResponse.version
Code IndexAdd Tabnine to your IDE (free)

How to use
version
method
in
io.vertx.core.http.HttpClientResponse

Best Java code snippets using io.vertx.core.http.HttpClientResponse.version (Showing top 20 results out of 315)

origin: vert-x3/vertx-examples

 @Override
 public void start() throws Exception {

  HttpClientOptions options = new HttpClientOptions().setProtocolVersion(HttpVersion.HTTP_2);

  vertx.createHttpClient(options
  ).getNow(8080, "localhost", "/", resp -> {
   System.out.println("Got response " + resp.statusCode() + " with protocol " + resp.version());
   resp.bodyHandler(body -> System.out.println("Got data " + body.toString("ISO-8859-1")));
  });
 }
}
origin: vert-x3/vertx-examples

 @Override
 public void start() throws Exception {

  // Note! in real-life you wouldn't often set trust all to true as it could leave you open to man in the middle attacks.

  HttpClientOptions options = new HttpClientOptions().
    setSsl(true).
    setUseAlpn(true).
    setProtocolVersion(HttpVersion.HTTP_2).
    setTrustAll(true);

  vertx.createHttpClient(options
  ).getNow(8443, "localhost", "/", resp -> {
   System.out.println("Got response " + resp.statusCode() + " with protocol " + resp.version());
   resp.bodyHandler(body -> System.out.println("Got data " + body.toString("ISO-8859-1")));
  });
 }
}
origin: vert-x3/vertx-examples

 @Override
 public void start() throws Exception {

  // Note! in real-life you wouldn't often set trust all to true as it could leave you open to man in the middle attacks.

  HttpClientOptions options = new HttpClientOptions().
    setSsl(true).
    setUseAlpn(true).
    setProtocolVersion(HttpVersion.HTTP_2).
    setTrustAll(true);

  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request = client.get(8443, "localhost", "/", resp -> {
   System.out.println("Got response " + resp.statusCode() + " with protocol " + resp.version());
   resp.bodyHandler(body -> System.out.println("Got data " + body.toString("ISO-8859-1")));
  });

  // Set handler for server side push
  request.pushHandler(pushedReq -> {
   System.out.println("Receiving pushed content");
   pushedReq.handler(pushedResp -> {
    pushedResp.bodyHandler(body -> System.out.println("Got pushed data " + body.toString("ISO-8859-1")));
   });
  });

  request.end();
 }
}
origin: eclipse-vertx/vert.x

@Test
public void testServerDoesNotSupportAlpn() throws Exception {
 waitFor(2);
 server.close();
 server = vertx.createHttpServer(createBaseServerOptions().setUseAlpn(false));
 server.requestHandler(req -> {
  assertEquals(HttpVersion.HTTP_1_1, req.version());
  req.response().end();
  complete();
 });
 startServer();
 client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, onSuccess(resp -> {
  assertEquals(HttpVersion.HTTP_1_1, resp.version());
  complete();
 })).exceptionHandler(this::fail).end();
 await();
}
origin: eclipse-vertx/vert.x

private void testClearText(boolean upgrade) throws Exception {
 ServerBootstrap bootstrap = createH2CServer((dec, enc) -> new Http2EventAdapter() {
  @Override
  public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream) throws Http2Exception {
   enc.writeHeaders(ctx, streamId, new DefaultHttp2Headers().status("200"), 0, true, ctx.newPromise());
   ctx.flush();
  }
 }, upgrade);
 ChannelFuture s = bootstrap.bind(DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT).sync();
 try {
  client.close();
  client = vertx.createHttpClient(clientOptions.setUseAlpn(false).setSsl(false).setHttp2ClearTextUpgrade(upgrade));
  client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath", onSuccess(resp1 -> {
   HttpConnection conn = resp1.request().connection();
   assertEquals(HttpVersion.HTTP_2, resp1.version());
   client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath", onSuccess(resp2 -> {
    assertSame(((HttpClientConnection)conn).channel(), ((HttpClientConnection)resp2.request().connection()).channel());
    testComplete();
   })).exceptionHandler(this::fail).end();
  })).exceptionHandler(this::fail).end();
  await();
 } finally {
  s.channel().close().sync();
 }
}
origin: eclipse-vertx/vert.x

client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath", onSuccess(resp -> {
 assertEquals(400, resp.statusCode());
 assertEquals(HttpVersion.HTTP_1_1, resp.version());
 resp.bodyHandler(body -> {
  testComplete();
origin: eclipse-vertx/vert.x

private void testStatusCode(int code, String statusMessage) {
 server.requestHandler(req -> {
  if (code != -1) {
   req.response().setStatusCode(code);
  }
  if (statusMessage != null) {
   req.response().setStatusMessage(statusMessage);
  }
  req.response().end();
 });
 server.listen(onSuccess(s -> {
  client.request(HttpMethod.GET, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, onSuccess(resp -> {
   int theCode;
   if (code == -1) {
    // Default code - 200
    assertEquals(200, resp.statusCode());
    theCode = 200;
   } else {
    theCode = code;
   }
   if (statusMessage != null && resp.version() != HttpVersion.HTTP_2) {
    assertEquals(statusMessage, resp.statusMessage());
   } else {
    assertEquals(HttpResponseStatus.valueOf(theCode).reasonPhrase(), resp.statusMessage());
   }
   testComplete();
  })).end();
 }));
 await();
}
origin: eclipse-vertx/vert.x

@Test
public void testClientDoesNotSupportAlpn() throws Exception {
 waitFor(2);
 server.requestHandler(req -> {
  assertEquals(HttpVersion.HTTP_1_1, req.version());
  req.response().end();
  complete();
 });
 startServer();
 client.close();
 client = vertx.createHttpClient(createBaseClientOptions().setProtocolVersion(HttpVersion.HTTP_1_1).setUseAlpn(false));
 client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, onSuccess(resp -> {
  assertEquals(HttpVersion.HTTP_1_1, resp.version());
  complete();
 })).exceptionHandler(this::fail).end();
 await();
}
origin: eclipse-vertx/vert.x

assertEquals(1, resp.request().streamId());
assertEquals(1, reqCount.get());
assertEquals(HttpVersion.HTTP_2, resp.version());
assertEquals(200, resp.statusCode());
assertEquals("OK", resp.statusMessage());
origin: eclipse-vertx/vert.x

response.version();
HttpMethod method = response.request().method();
if (method == HttpMethod.GET || method == HttpMethod.HEAD) {
origin: io.vertx/vertx-rx-java

/**
 * @return the version of the response
 */
public HttpVersion version() { 
 HttpVersion ret = delegate.version();
 return ret;
}
origin: io.vertx/vertx-core

@Test
public void testServerDoesNotSupportAlpn() throws Exception {
 waitFor(2);
 server.close();
 server = vertx.createHttpServer(createBaseServerOptions().setUseAlpn(false));
 server.requestHandler(req -> {
  assertEquals(HttpVersion.HTTP_1_1, req.version());
  req.response().end();
  complete();
 });
 startServer();
 client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, resp -> {
  assertEquals(HttpVersion.HTTP_1_1, resp.version());
  complete();
 }).exceptionHandler(this::fail).end();
 await();
}
origin: io.vertx/vertx-core

private void testClearText(boolean upgrade) throws Exception {
 ServerBootstrap bootstrap = createH2CServer((dec, enc) -> new Http2EventAdapter() {
  @Override
  public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream) throws Http2Exception {
   enc.writeHeaders(ctx, streamId, new DefaultHttp2Headers().status("200"), 0, true, ctx.newPromise());
   ctx.flush();
  }
 }, upgrade);
 ChannelFuture s = bootstrap.bind(DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT).sync();
 try {
  client.close();
  client = vertx.createHttpClient(clientOptions.setUseAlpn(false).setSsl(false).setHttp2ClearTextUpgrade(upgrade));
  client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath", resp1 -> {
   HttpConnection conn = resp1.request().connection();
   assertEquals(HttpVersion.HTTP_2, resp1.version());
   client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath", resp2 -> {
    assertSame(((HttpClientConnection)conn).channel(), ((HttpClientConnection)resp2.request().connection()).channel());
    testComplete();
   }).exceptionHandler(this::fail).end();
  }).exceptionHandler(this::fail).end();
  await();
 } finally {
  s.channel().close().sync();
 }
}
origin: io.vertx/vertx-core

@Test
public void testClientDoesNotSupportAlpn() throws Exception {
 waitFor(2);
 server.requestHandler(req -> {
  assertEquals(HttpVersion.HTTP_1_1, req.version());
  req.response().end();
  complete();
 });
 startServer();
 client.close();
 client = vertx.createHttpClient(createBaseClientOptions().setProtocolVersion(HttpVersion.HTTP_1_1).setUseAlpn(false));
 client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, resp -> {
  assertEquals(HttpVersion.HTTP_1_1, resp.version());
  complete();
 }).exceptionHandler(this::fail).end();
 await();
}
origin: io.vertx/vertx-core

client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath", resp -> {
 assertEquals(400, resp.statusCode());
 assertEquals(HttpVersion.HTTP_1_1, resp.version());
 resp.bodyHandler(body -> {
  testComplete();
origin: vert-x3/vertx-web

HttpClientRequest request = client.get(8443, "localhost", "/testLinkPreload.html", onSuccess(resp -> {
 assertEquals(200, resp.statusCode());
 assertEquals(HttpVersion.HTTP_2, resp.version());
 resp.bodyHandler(this::assertNotNull);
}));
origin: io.vertx/vertx-core

private void testStatusCode(int code, String statusMessage) {
 server.requestHandler(req -> {
  if (code != -1) {
   req.response().setStatusCode(code);
  }
  if (statusMessage != null) {
   req.response().setStatusMessage(statusMessage);
  }
  req.response().end();
 });
 server.listen(onSuccess(s -> {
  client.request(HttpMethod.GET, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, resp -> {
   int theCode;
   if (code == -1) {
    // Default code - 200
    assertEquals(200, resp.statusCode());
    theCode = 200;
   } else {
    theCode = code;
   }
   if (statusMessage != null && resp.version() != HttpVersion.HTTP_2) {
    assertEquals(statusMessage, resp.statusMessage());
   } else {
    assertEquals(HttpResponseStatus.valueOf(theCode).reasonPhrase(), resp.statusMessage());
   }
   testComplete();
  }).end();
 }));
 await();
}
origin: io.vertx/vertx-core

assertEquals(1, req.streamId());
assertEquals(1, reqCount.get());
assertEquals(HttpVersion.HTTP_2, resp.version());
assertEquals(200, resp.statusCode());
assertEquals("OK", resp.statusMessage());
origin: vert-x3/vertx-web

@Test
public void testNoHttp2Push() throws Exception {
 stat.setWebRoot("webroot/somedir3");
 router.route().handler(stat);
 HttpServer http2Server = vertx.createHttpServer(new HttpServerOptions()
  .setUseAlpn(true)
  .setSsl(true)
  .setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("tls/server-key.pem").setCertPath("tls/server-cert.pem")));
 http2Server.requestHandler(router).listen(8443);
 HttpClientOptions options = new HttpClientOptions()
  .setSsl(true)
  .setUseAlpn(true)
  .setProtocolVersion(HttpVersion.HTTP_2)
  .setPemTrustOptions(new PemTrustOptions().addCertPath("tls/server-cert.pem"));
 HttpClient client = vertx.createHttpClient(options);
 HttpClientRequest request = client.get(8443, "localhost", "/testLinkPreload.html", onSuccess(resp -> {
  assertEquals(200, resp.statusCode());
  assertEquals(HttpVersion.HTTP_2, resp.version());
  resp.bodyHandler(this::assertNotNull);
  testComplete();
 }));
 request.pushHandler(pushedReq -> pushedReq.handler(pushedResp -> {
  fail();
 }));
 request.end();
 await();
}
origin: io.vertx/vertx-core

response.version();
HttpMethod method = response.request().method();
if (method == HttpMethod.GET || method == HttpMethod.HEAD) {
io.vertx.core.httpHttpClientResponseversion

Popular methods of HttpClientResponse

  • statusCode
  • bodyHandler
    Convenience method for receiving the entire request body in one piece. This saves you having to manu
  • statusMessage
  • headers
  • exceptionHandler
  • endHandler
  • getHeader
    Return the first header value with the specified name
  • handler
  • pause
  • resume
  • request
  • cookies
  • request,
  • cookies,
  • netSocket,
  • customFrameHandler,
  • getTrailer,
  • streamPriorityHandler,
  • trailers,
  • fetch

Popular in Java

  • Reactive rest calls using spring rest template
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getResourceAsStream (ClassLoader)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Runner (org.openjdk.jmh.runner)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now