本文整理了Java中io.netty.handler.proxy.HttpProxyHandler.<init>()
方法的一些代码示例,展示了HttpProxyHandler.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpProxyHandler.<init>()
方法的具体详情如下:
包路径:io.netty.handler.proxy.HttpProxyHandler
类名称:HttpProxyHandler
方法名:<init>
暂无
代码示例来源:origin: relayrides/pushy
@Override
public ProxyHandler createProxyHandler() {
final HttpProxyHandler handler;
// For reasons that are not immediately clear, HttpProxyHandler doesn't allow null usernames/passwords if
// specified. If we want them to be null, we have to use the constructor that doesn't take a username/password
// at all.
if (this.username != null && this.password != null) {
handler = new HttpProxyHandler(this.proxyAddress, this.username, this.password);
} else {
handler = new HttpProxyHandler(this.proxyAddress);
}
return handler;
}
}
代码示例来源:origin: micronaut-projects/micronaut-core
switch (proxyType) {
case HTTP:
pipeline.addLast(HANDLER_HTTP_PROXY, new HttpProxyHandler(proxyAddress, username, password));
break;
case SOCKS:
switch (proxyType) {
case HTTP:
pipeline.addLast(HANDLER_HTTP_PROXY, new HttpProxyHandler(proxyAddress));
break;
case SOCKS:
代码示例来源:origin: jersey/jersey
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
// Enable HTTPS if necessary.
if ("https".equals(requestUri.getScheme())) {
// making client authentication optional for now; it could be extracted to configurable property
JdkSslContext jdkSslContext = new JdkSslContext(client.getSslContext(), true, ClientAuth.NONE);
p.addLast(jdkSslContext.newHandler(ch.alloc()));
}
// http proxy
Configuration config = jerseyRequest.getConfiguration();
final Object proxyUri = config.getProperties().get(ClientProperties.PROXY_URI);
if (proxyUri != null) {
final URI u = getProxyUri(proxyUri);
final String userName = ClientProperties.getValue(
config.getProperties(), ClientProperties.PROXY_USERNAME, String.class);
final String password = ClientProperties.getValue(
config.getProperties(), ClientProperties.PROXY_PASSWORD, String.class);
p.addLast(new HttpProxyHandler(new InetSocketAddress(u.getHost(),
u.getPort() == -1 ? 8080 : u.getPort()),
userName, password));
}
p.addLast(new HttpClientCodec());
p.addLast(new ChunkedWriteHandler());
p.addLast(new HttpContentDecompressor());
p.addLast(new JerseyClientHandler(NettyConnector.this, jerseyRequest, jerseyCallback, settableFuture));
}
});
代码示例来源:origin: jamesdbloom/mockserver
pipeline.addLast(new HttpProxyHandler(proxyConfiguration.getProxyAddress()));
} else if (proxyConfiguration.getType() == ProxyConfiguration.Type.SOCKS5) {
pipeline.addLast(new Socks5ProxyHandler(proxyConfiguration.getProxyAddress()));
代码示例来源:origin: eclipse-vertx/vert.x
case HTTP:
proxy = proxyUsername != null && proxyPassword != null
? new HttpProxyHandler(proxyAddr, proxyUsername, proxyPassword) : new HttpProxyHandler(proxyAddr);
break;
case SOCKS5:
代码示例来源:origin: glowroot/glowroot
private @Nullable HttpProxyHandler newHttpProxyHandlerIfNeeded(HttpProxyConfig httpProxyConfig,
@Nullable String passwordOverride) throws Exception {
String proxyHost = httpProxyConfig.host();
if (proxyHost.isEmpty()) {
return null;
}
int proxyPort = MoreObjects.firstNonNull(httpProxyConfig.port(), 80);
SocketAddress proxyAddress = new InetSocketAddress(proxyHost, proxyPort);
String username = httpProxyConfig.username();
if (username.isEmpty()) {
return new HttpProxyHandler(proxyAddress);
} else {
String password = getPassword(httpProxyConfig, passwordOverride);
return new HttpProxyHandler(proxyAddress, username, password);
}
}
代码示例来源:origin: io.vertx/vertx-core
case HTTP:
proxy = proxyUsername != null && proxyPassword != null
? new HttpProxyHandler(proxyAddr, proxyUsername, proxyPassword) : new HttpProxyHandler(proxyAddr);
break;
case SOCKS5:
代码示例来源:origin: com.relayrides/pushy
@Override
public ProxyHandler createProxyHandler() {
final HttpProxyHandler handler;
// For reasons that are not immediately clear, HttpProxyHandler doesn't allow null usernames/passwords if
// specified. If we want them to be null, we have to use the constructor that doesn't take a username/password
// at all.
if (this.username != null && this.password != null) {
handler = new HttpProxyHandler(this.proxyAddress, this.username, this.password);
} else {
handler = new HttpProxyHandler(this.proxyAddress);
}
return handler;
}
}
代码示例来源:origin: com.turo/pushy
@Override
public ProxyHandler createProxyHandler() {
final HttpProxyHandler handler;
// For reasons that are not immediately clear, HttpProxyHandler doesn't allow null usernames/passwords if
// specified. If we want them to be null, we have to use the constructor that doesn't take a username/password
// at all.
if (this.username != null && this.password != null) {
handler = new HttpProxyHandler(this.proxyAddress, this.username, this.password);
} else {
handler = new HttpProxyHandler(this.proxyAddress);
}
return handler;
}
}
代码示例来源:origin: reactor/reactor-netty
/**
* Return a new eventual {@link ProxyHandler}
*
* @return a new eventual {@link ProxyHandler}
*/
public final ProxyHandler newProxyHandler() {
InetSocketAddress proxyAddr = this.address.get();
String username = this.username;
String password = Objects.nonNull(username) && Objects.nonNull(this.password) ?
this.password.apply(username) : null;
switch (this.type) {
case HTTP:
return Objects.nonNull(username) && Objects.nonNull(password) ?
new HttpProxyHandler(proxyAddr, username, password) :
new HttpProxyHandler(proxyAddr);
case SOCKS4:
return Objects.nonNull(username) ? new Socks4ProxyHandler(proxyAddr, username) :
new Socks4ProxyHandler(proxyAddr);
case SOCKS5:
return Objects.nonNull(username) && Objects.nonNull(password) ?
new Socks5ProxyHandler(proxyAddr, username, password) :
new Socks5ProxyHandler(proxyAddr);
}
throw new IllegalArgumentException("Proxy type unsupported : " + this.type);
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* Return a new eventual {@link ProxyHandler}
*
* @return a new eventual {@link ProxyHandler}
*/
public final ProxyHandler newProxyHandler() {
InetSocketAddress proxyAddr = this.address.get();
String username = this.username;
String password = Objects.nonNull(username) && Objects.nonNull(this.password) ?
this.password.apply(username) : null;
switch (this.type) {
case HTTP:
return Objects.nonNull(username) && Objects.nonNull(password) ?
new HttpProxyHandler(proxyAddr, username, password) :
new HttpProxyHandler(proxyAddr);
case SOCKS4:
return Objects.nonNull(username) ? new Socks4ProxyHandler(proxyAddr, username) :
new Socks4ProxyHandler(proxyAddr);
case SOCKS5:
return Objects.nonNull(username) && Objects.nonNull(password) ?
new Socks5ProxyHandler(proxyAddr, username, password) :
new Socks5ProxyHandler(proxyAddr);
}
throw new IllegalArgumentException("Proxy type unsupported : " + this.type);
}
代码示例来源:origin: io.projectreactor.ipc/reactor-netty
/**
* Return a new eventual {@link ProxyHandler}
*
* @return a new eventual {@link ProxyHandler}
*/
public final ProxyHandler newProxyHandler() {
InetSocketAddress proxyAddr = this.address.get();
String username = this.username;
String password = Objects.nonNull(username) && Objects.nonNull(this.password) ?
this.password.apply(username) : null;
switch (this.type) {
case HTTP:
return Objects.nonNull(username) && Objects.nonNull(password) ?
new HttpProxyHandler(proxyAddr, username, password) :
new HttpProxyHandler(proxyAddr);
case SOCKS4:
return Objects.nonNull(username) ? new Socks4ProxyHandler(proxyAddr, username) :
new Socks4ProxyHandler(proxyAddr);
case SOCKS5:
return Objects.nonNull(username) && Objects.nonNull(password) ?
new Socks5ProxyHandler(proxyAddr, username, password) :
new Socks5ProxyHandler(proxyAddr);
}
throw new IllegalArgumentException("Proxy type unsupported : " + this.type);
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-client-spring
@Value.Derived
Optional<ChannelHandler> getHttpProxyHandler() {
if (StringUtils.hasText(getHost())) {
InetSocketAddress proxyAddress = new InetSocketAddress(getHost(), Optional.ofNullable(getPort()).orElse(8080));
HttpProxyHandler httpProxyHandler;
if (getUsername() != null) {
httpProxyHandler = new HttpProxyHandler(proxyAddress, getUsername(), getPassword());
} else {
httpProxyHandler = new HttpProxyHandler(proxyAddress);
}
return Optional.of(httpProxyHandler);
}
return Optional.empty();
}
代码示例来源:origin: org.wso2.transport.http/org.wso2.transport.http.netty
private void configureProxyServer(ChannelPipeline clientPipeline) {
if (proxyServerConfiguration != null && sslConfig != null) {
if (proxyServerConfiguration.getProxyUsername() != null
&& proxyServerConfiguration.getProxyPassword() != null) {
clientPipeline.addLast(Constants.PROXY_HANDLER,
new HttpProxyHandler(proxyServerConfiguration.getInetSocketAddress(),
proxyServerConfiguration.getProxyUsername(),
proxyServerConfiguration.getProxyPassword()));
} else {
clientPipeline.addLast(Constants.PROXY_HANDLER,
new HttpProxyHandler(proxyServerConfiguration.getInetSocketAddress()));
}
}
}
代码示例来源:origin: io.micronaut/http-client
switch (proxyType) {
case HTTP:
pipeline.addLast(HANDLER_HTTP_PROXY, new HttpProxyHandler(proxyAddress, username, password));
break;
case SOCKS:
switch (proxyType) {
case HTTP:
pipeline.addLast(HANDLER_HTTP_PROXY, new HttpProxyHandler(proxyAddress));
break;
case SOCKS:
代码示例来源:origin: com.simplyti.cloud/simple-server-clients
private ProxyHandler proxyHandler() {
switch(proxy.type()) {
case SOCKS5:
return new Socks5ProxyHandler(new InetSocketAddress(proxy.address().host(), proxy.address().port()));
case HTTP:
default:
return new HttpProxyHandler(new InetSocketAddress(proxy.address().host(), proxy.address().port()));
}
}
代码示例来源:origin: org.mock-server/mockserver-core
pipeline.addLast(new HttpProxyHandler(proxyConfiguration.getProxyAddress()));
} else if (proxyConfiguration.getType() == ProxyConfiguration.Type.SOCKS5) {
pipeline.addLast(new Socks5ProxyHandler(proxyConfiguration.getProxyAddress()));
代码示例来源:origin: monkeyWie/proxyee
case HTTP:
if (isAuth) {
proxyHandler = new HttpProxyHandler(inetSocketAddress,
config.getUser(), config.getPwd());
} else {
proxyHandler = new HttpProxyHandler(inetSocketAddress);
代码示例来源:origin: proxyee-down-org/pdown-core
case HTTP:
if (isAuth) {
proxyHandler = new HttpProxyHandler(inetSocketAddress,
config.getUser(), config.getPwd());
} else {
proxyHandler = new HttpProxyHandler(inetSocketAddress);
代码示例来源:origin: com.microsoft.azure/azure-cosmosdb-commons
public CompositeHttpClientBuilder<ByteBuf, ByteBuf> toHttpClientBuilder() {
if (configs == null) {
throw new IllegalArgumentException("configs is null");
}
DefaultSSLEngineFactory defaultSSLEngineFactory = new DefaultSSLEngineFactory();
CompositeHttpClientBuilder<ByteBuf, ByteBuf> builder = new CompositeHttpClientBuilder<ByteBuf, ByteBuf>();
if (maxPoolSize != null) {
builder = builder.withMaxConnections(maxPoolSize);
}
if (maxIdleConnectionTimeoutInMillis != null) {
builder = builder.withIdleConnectionsTimeoutMillis(maxIdleConnectionTimeoutInMillis);
}
builder = builder.pipelineConfigurator(pipeline -> {
LoggingHandler loggingHandler = getLoggingHandler();
if (loggingHandler != null) {
pipeline.addFirst(Constants.Properties.LOGGING_HANDLER_NAME, loggingHandler);
}
if(proxy != null) {
pipeline.addFirst(Constants.Properties.HTTP_PROXY_HANDLER_NAME, new HttpProxyHandler(proxy));
}
})
.appendPipelineConfigurator(new SslPipelineConfiguratorUsedWithProxy<HttpClientResponse<ByteBuf>,HttpClientRequest<ByteBuf>>(defaultSSLEngineFactory))
.appendPipelineConfigurator(createClientPipelineConfigurator(configs));
if (requestTimeoutInMillis != null) {
HttpClientConfig.Builder clientConfigBuilder = new HttpClientConfig.Builder();
clientConfigBuilder.readTimeout(requestTimeoutInMillis, TimeUnit.MILLISECONDS);
return builder.config(clientConfigBuilder.build());
}
return builder;
}
内容来源于网络,如有侵权,请联系作者删除!