java.net.http.HttpClient.Version#java.net.http.HttpClient.Redirect源码实例Demo

下面列出了java.net.http.HttpClient.Version#java.net.http.HttpClient.Redirect 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: milkman   文件: JavaRequestProcessor.java
@SneakyThrows
	private HttpClient buildClient() {
		Builder builder = HttpClient.newBuilder();
		if (!HttpOptionsPluginProvider.options().isHttp2Support()){
			builder.version(Version.HTTP_1_1);
		}

		if (HttpOptionsPluginProvider.options().isUseProxy()) {
			URL url = new URL(HttpOptionsPluginProvider.options().getProxyUrl());
			builder.proxy(new ProxyExclusionRoutePlanner(url, HttpOptionsPluginProvider.options().getProxyExclusion()).java());
			
			//we dont use Authenticator because it might result in an exception if there is a 401 response
			// see https://github.com/AdoptOpenJDK/openjdk-jdk11/blob/master/src/java.net.http/share/classes/jdk/internal/net/http/AuthenticationFilter.java#L263
			//we manually add Proxy-Authorization header instead
//			if (proxyCredentials != null) {
//				builder.authenticator(new Authenticator() {
//					@Override
//					protected PasswordAuthentication getPasswordAuthentication() {
//						return proxyCredentials;
//					}
//				});
//			}
		}

		if (!HttpOptionsPluginProvider.options().isCertificateValidation()) {
			disableSsl(builder);
		}
		
		if (HttpOptionsPluginProvider.options().isFollowRedirects()) {
			builder.followRedirects(Redirect.ALWAYS);
		}

		setupSslLegacyProtocolSupport(builder);

		return builder
				.build();
	}
 
源代码2 项目: r2cloud   文件: OreKitDataClient.java
public OreKitDataClient(List<String> urls) {
	if (urls == null || urls.isEmpty()) {
		throw new IllegalArgumentException("urls are blank. at least 1 is expected");
	}
	this.urls = urls;
	this.httpclient = HttpClient.newBuilder().version(Version.HTTP_2).followRedirects(Redirect.NORMAL).connectTimeout(Duration.ofMillis(TIMEOUT)).build();
}
 
源代码3 项目: r2cloud   文件: RestClient.java
public RestClient(String baseUrl) throws Exception {
	if (baseUrl == null) {
		this.baseUrl = "http://localhost:8097";
	} else {
		this.baseUrl = baseUrl;
	}
	this.httpclient = HttpClient.newBuilder().version(Version.HTTP_2).followRedirects(Redirect.NORMAL).connectTimeout(Duration.ofMinutes(1L)).build();
}
 
源代码4 项目: r2cloud   文件: R2ServerClient.java
public R2ServerClient(Configuration config) {
	this.config = config;
	this.hostname = config.getProperty("r2server.hostname");
	this.httpclient = HttpClient.newBuilder().version(Version.HTTP_2).followRedirects(Redirect.NORMAL).connectTimeout(Duration.ofMillis(config.getInteger("r2server.connectionTimeout"))).build();
}
 
源代码5 项目: r2cloud   文件: NoIpClient.java
public NoIpClient(String hostname, String username, String password) {
	this.hostname = hostname;
	this.username = username;
	this.password = password;
	this.httpclient = HttpClient.newBuilder().version(Version.HTTP_2).followRedirects(Redirect.NORMAL).connectTimeout(Duration.ofMinutes(1L)).build();
}
 
源代码6 项目: r2cloud   文件: ExternalIpClient.java
public ExternalIpClient(String host) {
	this.host = host;
	this.httpclient = HttpClient.newBuilder().version(Version.HTTP_2).followRedirects(Redirect.NORMAL).connectTimeout(Duration.ofMinutes(1L)).build();
}
 
源代码7 项目: feign   文件: Http2Client.java
public Http2Client() {
  this(HttpClient.newBuilder()
      .followRedirects(Redirect.ALWAYS)
      .version(Version.HTTP_2)
      .build());
}