io.vertx.ext.web.client.HttpResponse.getHeader()方法的使用及代码示例

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

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

HttpResponse.getHeader介绍

暂无

代码示例

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Return the first header value with the specified name
 * @param headerName the header name
 * @return the header value
 */
public String getHeader(String headerName) { 
 String ret = delegate.getHeader(headerName);
 return ret;
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * Return the first header value with the specified name
 * @param headerName the header name
 * @return the header value
 */
public String getHeader(String headerName) { 
 String ret = delegate.getHeader(headerName);
 return ret;
}

代码示例来源:origin: io.vertx/vertx-service-discovery

@Test
public void testPublicationAndConsumptionWithConfigurationAsWebClient(TestContext context) {
 Async async = context.async();
 // Publish the service
 Record record = HttpEndpoint.createRecord("hello-service", "localhost", 8080, "/foo");
 discovery.publish(record, rec -> {
  Record published = rec.result();
  HttpEndpoint.getWebClient(discovery,
   new JsonObject().put("name", "hello-service"),
   new JsonObject().put("keepAlive", false), found -> {
    context.assertTrue(found.succeeded());
    context.assertTrue(found.result() != null);
    WebClient client = found.result();
    client.get("/foo").send(ar -> {
     if (ar.failed()) {
      context.fail(ar.cause());
     }
     HttpResponse<Buffer> response = ar.result();
     context.assertEquals(response.statusCode(), 200);
     context.assertEquals(response.getHeader("connection"), "close");
     context.assertEquals(response.body().toString(), "hello");
     ServiceDiscovery.releaseServiceObject(discovery, client);
     discovery.unpublish(published.getRegistration(), v -> async.complete());
    });
   });
 });
}

代码示例来源:origin: vert-x3/vertx-service-discovery

@Test
public void testPublicationAndConsumptionWithConfigurationAsWebClient(TestContext context) {
 Async async = context.async();
 // Publish the service
 Record record = HttpEndpoint.createRecord("hello-service", "localhost", 8080, "/foo");
 discovery.publish(record, rec -> {
  Record published = rec.result();
  HttpEndpoint.getWebClient(discovery,
   new JsonObject().put("name", "hello-service"),
   new JsonObject().put("keepAlive", false), found -> {
    context.assertTrue(found.succeeded());
    context.assertTrue(found.result() != null);
    WebClient client = found.result();
    client.get("/foo").send(ar -> {
     if (ar.failed()) {
      context.fail(ar.cause());
     }
     HttpResponse<Buffer> response = ar.result();
     context.assertEquals(response.statusCode(), 200);
     context.assertEquals(response.getHeader("connection"), "close");
     context.assertEquals(response.body().toString(), "hello");
     ServiceDiscovery.releaseServiceObject(discovery, client);
     discovery.unpublish(published.getRegistration(), v -> async.complete());
    });
   });
 });
}

代码示例来源:origin: EliMirren/VX-API-Gateway

if (tranHeaders != null && tranHeaders.size() > 0) {
  tranHeaders.forEach(h -> {
    rct.response().putHeader(h, result.getHeader(h) == null ? "" : result.getHeader(h));
  });
String token = res.result().getHeader(getTokenName);
if (token != null && !"".equals(token)) {
  rct.session().put(saveTokenName, token);

代码示例来源:origin: io.vertx/vertx-web-client

@Test
public void testInvalidRedirection() throws Exception {
 server.requestHandler(req -> {
  assertEquals(HttpMethod.POST, req.method());
  assertEquals("/redirect", req.path());
  req.response().setStatusCode(302).putHeader("Location", "http://www.google.com").end();
 });
 startServer();
 HttpRequest<Buffer> builder = client
  .post("/redirect")
  .followRedirects(true);
 builder.send(onSuccess(resp -> {
  assertEquals(302, resp.statusCode());
  assertEquals("http://www.google.com", resp.getHeader("Location"));
  assertNull(resp.body());
  complete();
 }));
 await();
}

代码示例来源:origin: io.vertx/vertx-web-client

@Test
public void testRedirectLimit() throws Exception {
 String location = "http://" + DEFAULT_HTTP_HOST + ":" + DEFAULT_HTTP_PORT + "/redirect";
 server.requestHandler(req -> {
  assertEquals(HttpMethod.GET, req.method());
  assertEquals("/redirect", req.path());
  req.response().setStatusCode(302).putHeader("Location", location).end();
 });
 startServer();
 HttpRequest<Buffer> builder = client
  .get("/redirect")
  .followRedirects(true);
 builder.send(onSuccess(resp -> {
  assertEquals(302, resp.statusCode());
  assertEquals(location, resp.getHeader("Location"));
  assertNull(resp.body());
  complete();
 }));
 await();
}

代码示例来源:origin: io.vertx/vertx-web-client

} else {
 assertEquals(301, resp.statusCode());
 assertEquals(location, resp.getHeader("location"));

相关文章