本文整理汇总了Java中io.vertx.ext.web.client.WebClientOptions.setUserAgent方法的典型用法代码示例。如果您正苦于以下问题:Java WebClientOptions.setUserAgent方法的具体用法?Java WebClientOptions.setUserAgent怎么用?Java WebClientOptions.setUserAgent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.web.client.WebClientOptions
的用法示例。
在下文中一共展示了WebClientOptions.setUserAgent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initWebClient
import io.vertx.ext.web.client.WebClientOptions; //导入方法依赖的package包/类
private WebClient initWebClient() {
if (this.client == null) {
final WebClientOptions wco = new WebClientOptions();
final String proxyHost = this.getConsumerConfig().getProxy();
final int proxyPort = this.getConsumerConfig().getProxyPort();
if ((proxyHost != null) && (proxyPort > 0)) {
final ProxyOptions po = new ProxyOptions();
wco.setProxyOptions(po);
po.setHost(proxyHost).setPort(proxyPort);
}
// TODO: more options
wco.setUserAgent("SFDC VertX REST Provider");
wco.setTryUseCompression(true);
this.client = WebClient.create(this.vertx, wco);
}
return this.client;
}
示例2: login
import io.vertx.ext.web.client.WebClientOptions; //导入方法依赖的package包/类
@Override
protected void login(final Future<AuthInfo> futureAuthinfo) {
final WebClientOptions wco = new WebClientOptions();
final String proxyHost = this.getAuthConfig().getProxy();
final int proxyPort = this.getAuthConfig().getProxyPort();
if ((proxyHost != null) && (proxyPort > 0)) {
final ProxyOptions po = new ProxyOptions();
wco.setProxyOptions(po);
po.setHost(proxyHost).setPort(proxyPort);
}
wco.setUserAgent("SDFC VertX Authenticator");
wco.setTryUseCompression(true);
final WebClient authClient = WebClient.create(this.vertx, wco);
final Buffer body = this.getAuthBody(this.getAuthConfig().getSfdcUser(),
this.getAuthConfig().getSfdcPassword());
if (!this.shuttingDown && !this.shutdownCompleted) {
authClient.post(Constants.TLS_PORT, this.getAuthConfig().getServerURL(), Constants.AUTH_SOAP_LOGIN)
.putHeader("Content-Type", "text/xml").ssl(true).putHeader("SOAPAction", "Login")
.putHeader("PrettyPrint", "Yes").sendBuffer(body, postReturn -> {
this.resultOfAuthentication(postReturn, futureAuthinfo);
});
} else {
this.shutdownCompleted = true;
futureAuthinfo.fail("Auth disruped by stop command");
}
}
示例3: testAPIListening
import io.vertx.ext.web.client.WebClientOptions; //导入方法依赖的package包/类
@Test
public void testAPIListening(final TestContext context) {
final Async async = context.async();
final WebClientOptions wco = new WebClientOptions();
wco.setUserAgent("SDFC VertX Unit Tester");
wco.setTryUseCompression(true);
final WebClient client = WebClient.create(this.vertx, wco);
client.get(8044, "localhost", "/api").send(result -> {
if (result.succeeded()) {
context.assertEquals(200, result.result().statusCode());
} else {
context.fail(result.cause());
}
async.complete();
});
}
示例4: initWebClient
import io.vertx.ext.web.client.WebClientOptions; //导入方法依赖的package包/类
private WebClient initWebClient() {
if (this.client == null) {
final WebClientOptions wco = new WebClientOptions();
final String proxyHost = this.getListenerConfig().getProxy();
final int proxyPort = this.getListenerConfig().getProxyPort();
if ((proxyHost != null) && (proxyPort > 0)) {
final ProxyOptions po = new ProxyOptions();
wco.setProxyOptions(po);
po.setHost(proxyHost).setPort(proxyPort);
}
// TODO: more options
wco.setUserAgent("SDFC VertX EventBus Client");
wco.setTryUseCompression(true);
this.client = WebClient.create(this.vertx, wco);
}
return this.client;
}
示例5: initWebClientOptions
import io.vertx.ext.web.client.WebClientOptions; //导入方法依赖的package包/类
private WebClientOptions initWebClientOptions(Request request) {
WebClientOptions options = new WebClientOptions();
options.setKeepAlive(true).setReuseAddress(true);
if (Preconditions.isNotBlank(request.getUserAgent())) {
options.setUserAgent(request.getUserAgent());
}
if (Preconditions.isNotBlank(request.getUrl())) {
try {
url = new URL(request.getUrl());
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
if (Preconditions.isNotBlank(request.getProxy())) {
ProxyOptions proxyOptions = new ProxyOptions();
proxyOptions.setHost(request.getProxy().getIp());
proxyOptions.setPort(request.getProxy().getPort());
options.setProxyOptions(proxyOptions);
}
if (Preconditions.isNotBlank(request.getHeader())) {
header = request.getHeader();
}
return options;
}