当前位置: 首页>>代码示例>>Java>>正文


Java HttpRequest类代码示例

本文整理汇总了Java中io.vertx.ext.web.client.HttpRequest的典型用法代码示例。如果您正苦于以下问题:Java HttpRequest类的具体用法?Java HttpRequest怎么用?Java HttpRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpRequest类属于io.vertx.ext.web.client包,在下文中一共展示了HttpRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postToDestination

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
private void postToDestination(final PostRetry payload) {
	this.initWebClient();
	final HttpRequest<Buffer> request = this.initWebPostRequest(this.getConsumerConfig().getUrl());
	request.sendBuffer(payload.body, result -> {
		// Retry if it didn't work
		if (result.failed()) {
			this.logger.error(result.cause());
			this.processError(payload);
		} else {
			final HttpResponse<Buffer> response = result.result();
			// Check for return code
			if ((response.statusCode() >= 200) && (response.statusCode() < 300)) {
				// We are good
				this.logger.info("Successful post:" + payload.body.toString());
			} else {
				this.processError(payload);
			}
		}
	});
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:21,代码来源:RestConsumer.java

示例2: step2ActionHandshake

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
private void step2ActionHandshake() {
	if (this.shuttingDown || this.shutdownCompleted) {
		this.shutdownCompleted = true;
		return;
	}
	final HttpRequest<Buffer> request = this.initWebPostRequest(Constants.URL_HANDSHAKE);
	final JsonArray body = this.getHandshakeBody();

	request.sendJson(body, postReturn -> {
		if (postReturn.succeeded()) {
			this.step2ResultHandshake(postReturn.result());
		} else {
			this.logger.error(postReturn.cause());
		}
	});
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:17,代码来源:CometD.java

示例3: step3ActionAdvice

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
private void step3ActionAdvice(final JsonObject handshakeResult) {
	if (this.shuttingDown || this.shutdownCompleted) {
		this.shutdownCompleted = true;
		return;
	}

	final JsonArray body = this.getAdviceBody();
	final HttpRequest<Buffer> request = this.initWebPostRequest(Constants.URL_CONNECT);
	request.sendJson(body, postReturn -> {
		if (postReturn.succeeded()) {
			this.step3ResultAdvice(postReturn.result());
		} else {
			this.logger.error(postReturn.cause());
		}
	});
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:17,代码来源:CometD.java

示例4: step4ActionSubscribe

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
private void step4ActionSubscribe() {
	if (this.shuttingDown || this.shutdownCompleted) {
		this.shutdownCompleted = true;
		return;
	}

	final JsonArray body = this.getSubscriptionBody();
	final HttpRequest<Buffer> request = this.initWebPostRequest(Constants.URL_SUBSCRIBE);

	request.sendJson(body, postReturn -> {
		if (postReturn.succeeded()) {
			this.step4ResultSubscribe(postReturn.result());
		} else {
			this.logger.error(postReturn.cause());
		}
	});
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:18,代码来源:CometD.java

示例5: buildRequest

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
private HttpRequest<JsonObject> buildRequest(String requestURI, RequestParameters parameters) {
  HttpRequest<JsonObject> request = client.post(requestURI)
                                          .as(BodyCodec.jsonObject())
                                          .putHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
                                          .setQueryParam("properties", parameters.getProperties().toString())
                                          .setQueryParam("pipelineLanguage", parameters.getLanguage().name());
  if (options.getUsername() != null && options.getPassword() != null) {
    request.putHeader("Authorization",
                      "Basic " + Base64.getEncoder().encodeToString(String.join(":", options.getUsername(), options.getPassword()).getBytes()));
  }
  if (parameters.getPattern() != null) {
    request.setQueryParam("pattern", parameters.getPattern())
           .setQueryParam("filter", String.valueOf(parameters.isFilter()));
  }
  return request;
}
 
开发者ID:shikeio,项目名称:vertx-corenlp-client,代码行数:17,代码来源:CoreNLPClientImpl.java

示例6: testImplicitMode

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
public void testImplicitMode() {
    vertx = Vertx.vertx();
    WebClient client = WebClient.create(vertx);
    HttpRequest<Buffer> request = client.postAbs("http://admin:[email protected]:8080/oauth/authorize?response_type=token&scope=read%20write&client_id=myClientId&redirect_uri=http://example.com");
    request.putHeader("Authorization", getHeader());
    request.send(ar -> {
        if (ar.succeeded()) {
            HttpResponse<Buffer> response = ar.result();
            //String location = response.getHeader("Location");
            String body = response.bodyAsString();
            System.out.println("Implicit Mode Get Token" + body + " status code" + response.statusCode() + " Location=");
        } else {
            System.out.println("Something went wrong " + ar.cause().getMessage());
        }
    });
}
 
开发者ID:openmg,项目名称:metagraph-auth,代码行数:17,代码来源:VertxWebTest.java

示例7: renewSelf

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
/**
 * Renews the current token.
 *
 * @param leaseDurationInSecond the extension in second
 * @param resultHandler         the callback invoked with the result
 */
public void renewSelf(long leaseDurationInSecond, Handler<AsyncResult<Auth>> resultHandler) {
  JsonObject payload = null;
  if (leaseDurationInSecond > 0) {
    payload = new JsonObject().put("increment", leaseDurationInSecond);
  }
  HttpRequest<Buffer> request = client.post("/v1/auth/token/renew-self")
    .putHeader(TOKEN_HEADER, Objects.requireNonNull(getToken(), "The token must not be null"));

  Handler<AsyncResult<HttpResponse<Buffer>>> handler = ar -> {
    if (ar.failed()) {
      resultHandler.handle(VaultException.toFailure("Unable to access the Vault", ar.cause()));
      return;
    }
    manageAuthResult(resultHandler, ar.result());
  };

  if (payload != null) {
    request.sendJsonObject(payload, handler);
  } else {
    request.send(handler);
  }
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:29,代码来源:SlimVaultClient.java

示例8: pathMultiSimpleLabel

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
/**
 * Call path_multi_simple_label with empty body.
 * @param colorSimple Parameter color_simple inside path
 * @param colorLabel Parameter color_label inside path
 * @param handler The handler for the asynchronous request
 */
public void pathMultiSimpleLabel(
    String colorSimple,
    List<Object> colorLabel,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (colorSimple == null) throw new RuntimeException("Missing parameter colorSimple in path");
    if (colorLabel == null) throw new RuntimeException("Missing parameter colorLabel in path");


    // Generate the uri
    String uri = "/path/multi/{color_simple}{.color_label}/test";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color_simple}", this.renderPathParam("color_simple", colorSimple));
    uri = uri.replace("{color_label}", this.renderPathArrayLabel("color_label", colorLabel));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:31,代码来源:ApiClient.java

示例9: pathMultiSimpleMatrix

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
/**
 * Call path_multi_simple_matrix with empty body.
 * @param colorSimple Parameter color_simple inside path
 * @param colorMatrix Parameter color_matrix inside path
 * @param handler The handler for the asynchronous request
 */
public void pathMultiSimpleMatrix(
    String colorSimple,
    List<Object> colorMatrix,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (colorSimple == null) throw new RuntimeException("Missing parameter colorSimple in path");
    if (colorMatrix == null) throw new RuntimeException("Missing parameter colorMatrix in path");


    // Generate the uri
    String uri = "/path/multi/{color_simple}{;color_matrix}/test";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color_simple}", this.renderPathParam("color_simple", colorSimple));
    uri = uri.replace("{color_matrix}", this.renderPathArrayMatrix("color_matrix", colorMatrix));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:31,代码来源:ApiClient.java

示例10: pathMultiLabelMatrix

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
/**
 * Call path_multi_label_matrix with empty body.
 * @param colorLabel Parameter color_label inside path
 * @param colorMatrix Parameter color_matrix inside path
 * @param handler The handler for the asynchronous request
 */
public void pathMultiLabelMatrix(
    List<Object> colorLabel,
    Map<String, Object> colorMatrix,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (colorLabel == null) throw new RuntimeException("Missing parameter colorLabel in path");
    if (colorMatrix == null) throw new RuntimeException("Missing parameter colorMatrix in path");


    // Generate the uri
    String uri = "/path/multi/{.color_label}{;color_matrix*}/test";
    uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template
    uri = uri.replace("{color_label}", this.renderPathArrayLabel("color_label", colorLabel));
    uri = uri.replace("{color_matrix}", this.renderPathObjectMatrixExplode("color_matrix", colorMatrix));


    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:31,代码来源:ApiClient.java

示例11: queryFormNoexplodeEmpty

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
/**
 * Call query_form_noexplode_empty with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormNoexplodeEmpty(
    String color,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (color == null) throw new RuntimeException("Missing parameter color");


    // Generate the uri
    String uri = "/query/form/noexplode/empty";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addQueryParam("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:25,代码来源:ApiClient.java

示例12: queryFormNoexplodeString

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
/**
 * Call query_form_noexplode_string with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormNoexplodeString(
    String color,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (color == null) throw new RuntimeException("Missing parameter color");


    // Generate the uri
    String uri = "/query/form/noexplode/string";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addQueryParam("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:25,代码来源:ApiClient.java

示例13: queryFormNoexplodeArray

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
/**
 * Call query_form_noexplode_array with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormNoexplodeArray(
    List<Object> color,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (color == null) throw new RuntimeException("Missing parameter color");


    // Generate the uri
    String uri = "/query/form/noexplode/array";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addQueryArrayForm("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:25,代码来源:ApiClient.java

示例14: queryFormNoexplodeObject

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
/**
 * Call query_form_noexplode_object with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormNoexplodeObject(
    Map<String, Object> color,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (color == null) throw new RuntimeException("Missing parameter color");


    // Generate the uri
    String uri = "/query/form/noexplode/object";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addQueryObjectForm("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:25,代码来源:ApiClient.java

示例15: queryFormExplodeEmpty

import io.vertx.ext.web.client.HttpRequest; //导入依赖的package包/类
/**
 * Call query_form_explode_empty with empty body.
 * @param color Parameter color inside query
 * @param handler The handler for the asynchronous request
 */
public void queryFormExplodeEmpty(
    String color,
    Handler<AsyncResult<HttpResponse>> handler) {
    // Check required params
    if (color == null) throw new RuntimeException("Missing parameter color");


    // Generate the uri
    String uri = "/query/form/explode/empty";

    HttpRequest request = client.get(uri);

    MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap();
    if (color != null) this.addQueryParam("color", color, request);


    this.renderAndAttachCookieHeader(request, requestCookies);
    request.send(handler);
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:25,代码来源:ApiClient.java


注:本文中的io.vertx.ext.web.client.HttpRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。