All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xingyuv.http.support.java11.DefaultProxySelector Maven / Gradle / Ivy

package com.xingyuv.http.support.java11;

import com.xingyuv.http.config.HttpConfig;
import com.xingyuv.http.exception.SimpleHttpException;

import java.io.IOException;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.util.Collections;
import java.util.List;

/**
 * 

* 默认代理选择器 *

* * @author yangkai.shen * @date Created in 2020-04-29 15:59 */ public class DefaultProxySelector extends ProxySelector { private HttpConfig httpConfig; public DefaultProxySelector(HttpConfig httpConfig) { this.httpConfig = httpConfig; } @Override public List select(URI uri) { return Collections.singletonList(httpConfig.getProxy()); } @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { throw new SimpleHttpException("Proxy connect failed!"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy