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

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

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

HttpRequest.sendForm介绍

暂无

代码示例

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

@Override
 public void start() throws Exception {

  WebClient client = WebClient.create(vertx);

  MultiMap form = MultiMap.caseInsensitiveMultiMap();
  form.add("firstName", "Dale");
  form.add("lastName", "Cooper");
  form.add("male", "true");

  client.post(8080, "localhost", "/").sendForm(form, ar -> {
   if (ar.succeeded()) {
    HttpResponse<Buffer> response = ar.result();
    System.out.println("Got HTTP response with status " + response.statusCode());
   } else {
    ar.cause().printStackTrace();
   }
  });
 }
}

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

@Override
 public void start() throws Exception {
  WebClient client = WebClient.create(vertx);

  MultiMap form = MultiMap.caseInsensitiveMultiMap();
  form.add("firstName", "Dale");
  form.add("lastName", "Cooper");
  form.add("male", "true");

  client
   .post(8080, "localhost", "/")
   .putHeader("content-type", "multipart/form-data")
   .sendForm(form, ar -> {
    if (ar.succeeded()) {
     HttpResponse<Buffer> response = ar.result();
     System.out.println("Got HTTP response with status " + response.statusCode());
    } else {
     ar.cause().printStackTrace();
    }
   });
 }
}

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

/**
 * Like {@link io.vertx.rxjava.ext.web.client.HttpRequest#send} but with an HTTP request <code>body</code> multimap encoded as form and the content type
 * set to <code>application/x-www-form-urlencoded</code>.
 * <p>
 * When the content type header is previously set to <code>multipart/form-data</code> it will be used instead.
 * @param body the body
 * @param handler 
 */
public void sendForm(io.vertx.rxjava.core.MultiMap body, Handler<AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>> handler) { 
 delegate.sendForm(body.getDelegate(), new Handler<AsyncResult<io.vertx.ext.web.client.HttpResponse<T>>>() {
  public void handle(AsyncResult<io.vertx.ext.web.client.HttpResponse<T>> ar) {
   if (ar.succeeded()) {
    handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.web.client.HttpResponse.newInstance(ar.result(), __typeArg_0)));
   } else {
    handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
   }
  }
 });
}

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

/**
 * Like {@link io.vertx.rxjava.ext.web.client.HttpRequest#send} but with an HTTP request <code>body</code> multimap encoded as form and the content type
 * set to <code>application/x-www-form-urlencoded</code>.
 * <p>
 * When the content type header is previously set to <code>multipart/form-data</code> it will be used instead.
 * @param body the body
 * @param handler 
 */
public void sendForm(io.vertx.rxjava.core.MultiMap body, Handler<AsyncResult<io.vertx.rxjava.ext.web.client.HttpResponse<T>>> handler) { 
 delegate.sendForm(body.getDelegate(), new Handler<AsyncResult<io.vertx.ext.web.client.HttpResponse<T>>>() {
  public void handle(AsyncResult<io.vertx.ext.web.client.HttpResponse<T>> ar) {
   if (ar.succeeded()) {
    handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.web.client.HttpResponse.newInstance(ar.result(), __typeArg_0)));
   } else {
    handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
   }
  }
 });
}

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

@Test
public void testFormUrlEncoded() throws Exception {
 server.requestHandler(req -> {
  req.setExpectMultipart(true);
  req.endHandler(v -> {
   assertEquals("param1_value", req.getFormAttribute("param1"));
   req.response().end();
  });
 });
 startServer();
 MultiMap form = MultiMap.caseInsensitiveMultiMap();
 form.add("param1", "param1_value");
 HttpRequest<Buffer> builder = client.post("/somepath");
 builder.sendForm(form, onSuccess(resp -> complete()));
 await();
}

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

@Test
public void testFormMultipart() throws Exception {
 server.requestHandler(req -> {
  req.setExpectMultipart(true);
  req.endHandler(v -> {
   assertEquals("param1_value", req.getFormAttribute("param1"));
   req.response().end();
  });
 });
 startServer();
 MultiMap form = MultiMap.caseInsensitiveMultiMap();
 form.add("param1", "param1_value");
 HttpRequest<Buffer> builder = client.post("/somepath");
 builder.putHeader("content-type", "multipart/form-data");
 builder.sendForm(form, onSuccess(resp -> complete()));
 await();
}

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

request.queryParams().addAll(queryParams);
trackInfo.setRequestTime(Instant.now());
request.sendForm(bodyParams, res -> {
  trackInfo.setResponseTime(Instant.now());
  if (res.succeeded()) {

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

req.send(handler);
req.sendBuffer(Buffer.buffer(), handler);
req.sendForm(new CaseInsensitiveHeaders().add("a", "b"), handler);
req.sendJson("", handler);
req.sendJsonObject(new JsonObject(), handler);

相关文章