org.vertx.java.core.http.HttpClient.get()方法的使用及代码示例

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

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

HttpClient.get介绍

[英]This method returns an HttpClientRequest instance which represents an HTTP GET request with the specified uri.

When an HTTP response is received from the server the responseHandler is called passing in the response.
[中]此方法返回一个HttpClientRequest实例,该实例表示具有指定uri的HTTP GET请求。
当从服务器接收到HTTP响应时,将调用responseHandler传递响应。

代码示例

代码示例来源:origin: vert-x/mod-lang-php

/**
 * Executes a GET request.
 */
public HttpClientRequest get(Env env, StringValue uri, Value handler) {
 PhpTypes.assertCallable(env, handler, "Argument to Vertx\\Http\\HttpClient::get() must be callable.");
 return new HttpClientRequest(client.get(uri.toString(), createResponseHandler(env, handler)));
}

代码示例来源:origin: org.vert-x/vertx-platform

uri = new StringBuffer("http://").append(DEFAULT_REPO_HOST).append(uri).toString();
HttpClientRequest req = client.get(uri, new Handler<HttpClientResponse>() {
 public void handle(HttpClientResponse resp) {
  if (resp.statusCode == 200) {

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

protected void sendRequest(String scheme, String host, int port, String uri, Handler<HttpClientResponse> respHandler) {
 final String proxyHost = getProxyHost();
 if (proxyHost != null) {
  // We use an absolute URI
  uri = scheme + "://" + host + ":" + port + uri;
 }
 HttpClientRequest req = client.get(uri, respHandler);
 if (proxyHost != null){
  if (isUseDestinationHostHeaderForProxy()) {
   req.putHeader("host", host);
  } else {
   req.putHeader("host", proxyHost);
  }
 } else {
  req.putHeader("host", host);
 }
 if (getBasicAuth() != null) {
  log.debug("Using HTTP Basic Authorization");
  req.putHeader("Authorization","Basic " + getBasicAuth());
 }
 req.putHeader("user-agent", "Vert.x Module Installer");
 req.end();
}

相关文章