本文整理了Java中org.vertx.java.core.http.HttpClient.setPort()
方法的一些代码示例,展示了HttpClient.setPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.setPort()
方法的具体详情如下:
包路径:org.vertx.java.core.http.HttpClient
类名称:HttpClient
方法名:setPort
[英]Set the port that the client will attempt to connect to the server on to port. The default value is 80
[中]将客户端尝试连接到服务器的端口设置为端口。默认值为80
代码示例来源:origin: stackoverflow.com
HttpClient client = vertx.createHttpClient();
String proxyHost = System.getProperty("http.proxyHost", "none");
Integer proxyPort = Integer.valueOf(System.getProperty("http.proxyPort", "80"));
if(!"none".equalsIgnoreCase(proxyHost)){
client.setHost(proxyHost);
client.setPort(proxyPort);
}
代码示例来源:origin: jboss-fuse/fabric8
protected HttpClient createClient(URL url) throws MalformedURLException {
// lets create a client
HttpClient client = vertx.createHttpClient();
client.setHost(url.getHost());
client.setPort(url.getPort());
return client;
}
代码示例来源:origin: com.englishtown/vertx-mod-when
protected <T> HttpClient createClient(URI url, final Deferred<T> d) {
if (url == null) throw new IllegalArgumentException("url is null");
if (!url.isAbsolute()) throw new IllegalArgumentException("url must be absolute");
int port = (url.getPort() > 0) ? url.getPort() : 80;
return vertx.createHttpClient()
.setHost(url.getHost())
.setPort(port)
.setConnectTimeout(CONNECT_TIMEOUT)
.exceptionHandler(t -> d.reject(t));
}
代码示例来源:origin: vert-x/mod-lang-php
/**
* Sets the HTTP port.
*/
public HttpClient port(Env env, NumberValue port) {
PhpTypes.assertNotNull(env, port, "Port to Vertx\\Http\\HttpClient::port() must be an integer.");
client.setPort(port.toInt());
return this;
}
代码示例来源:origin: io.vertx/vertx-platform
protected HttpClient createClient(String scheme, String host, int port) {
if (client != null) {
throw new IllegalStateException("Client already created");
}
client = vertx.createHttpClient();
client.setKeepAlive(false); // Not all servers will allow keep alive connections
if (proxyHost != null) {
client.setHost(proxyHost);
if (proxyPort != 80) {
client.setPort(proxyPort);
} else {
client.setPort(80);
}
} else {
client.setHost(host);
client.setPort(port);
}
if (scheme.equals("https")) {
client.setSSL(true);
}
client.exceptionHandler(new Handler<Throwable>() {
public void handle(Throwable t) {
end(false);
}
});
return client;
}
代码示例来源:origin: boonproject/boon
private void connect() {
int index = this.currentIndex.get();
int oldIndex = index;
if (index + 1 == hosts.length) {
index = 0;
} else {
index++;
}
if (this.currentIndex.compareAndSet(oldIndex, index)) {
final URI uri = this.hosts[index];
logger.info("Connecting to ", uri);
httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
.setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
httpClient.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable throwable) {
if (throwable instanceof ConnectException) {
closed.set(true);
} else {
logger.error(throwable, "Unable to connect to ", uri);
}
}
});
configureSSL(httpClient);
closed.set(false);
}
}
代码示例来源:origin: boonproject/boon
private void connect() {
int index = this.currentIndex.get();
int oldIndex = index;
if (index + 1 == hosts.length) {
index = 0;
} else {
index++;
}
if (this.currentIndex.compareAndSet(oldIndex, index)) {
final URI uri = this.hosts[index];
logger.info("Connecting to ", uri);
httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
.setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
httpClient.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable throwable) {
if (throwable instanceof ConnectException) {
closed.set(true);
} else {
logger.error(throwable, "Unable to connect to ", uri);
}
}
});
configureSSL(httpClient);
closed.set(false);
}
}
代码示例来源:origin: io.fastjson/etcd-client
private void connect() {
int index = this.currentIndex.get();
int oldIndex = index;
if (index + 1 == hosts.length) {
index = 0;
} else {
index++;
}
if (this.currentIndex.compareAndSet(oldIndex, index)) {
final URI uri = this.hosts[index];
logger.info("Connecting to ", uri);
httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
.setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
httpClient.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable throwable) {
if (throwable instanceof ConnectException) {
closed.set(true);
} else {
logger.error(throwable, "Unable to connect to ", uri);
}
}
});
configureSSL(httpClient);
closed.set(false);
}
}
代码示例来源:origin: org.vert-x/vertx-platform
client.setHost(proxyHost);
if (proxyPort != 80) {
client.setPort(proxyPort);
} else {
client.setPort(80);
client.setPort(repoPort);
代码示例来源:origin: liveoak-io/liveoak
@Override
public void createMember(RequestContext ctx, ResourceState state, Responder responder) {
String path = (String) state.getProperty("path");
String destination = (String) state.getProperty("destination");
String contentType = (String) state.getProperty("content-type");
if (contentType == null) {
contentType = "application/json";
}
ResourceCodec codec = this.codecManager.getResourceCodec(new MediaType(contentType));
if (codec == null) {
responder.internalError("content-type not supported: " + contentType);
return;
}
try {
URI destinationUri = new URI(destination);
HttpClient httpClient = this.vertx.createHttpClient();
httpClient.setHost(destinationUri.getHost());
httpClient.setPort(destinationUri.getPort());
SecurityContext requestSecurityContext = ctx.securityContext();
HttpSubscription sub = new HttpSubscription(httpClient, path, destinationUri, codec, requestSecurityContext);
this.subscriptionManager.addSubscription(sub);
responder.resourceCreated(new HttpSubscriptionResource(this, sub));
} catch (URISyntaxException e) {
responder.internalError(e.getMessage());
}
}
内容来源于网络,如有侵权,请联系作者删除!