< prev index next >

src/java.net.http/share/classes/jdk/internal/net/http/HttpClientBuilderImpl.java

Print this page




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.internal.net.http;
  27 
  28 import java.net.Authenticator;
  29 import java.net.CookieHandler;
  30 import java.net.ProxySelector;

  31 import java.util.concurrent.Executor;
  32 import javax.net.ssl.SSLContext;
  33 import javax.net.ssl.SSLParameters;
  34 import java.net.http.HttpClient;
  35 import jdk.internal.net.http.common.Utils;
  36 import static java.util.Objects.requireNonNull;
  37 
  38 public class HttpClientBuilderImpl implements HttpClient.Builder {
  39 
  40     CookieHandler cookieHandler;

  41     HttpClient.Redirect followRedirects;
  42     ProxySelector proxy;
  43     Authenticator authenticator;
  44     HttpClient.Version version;
  45     Executor executor;
  46     // Security parameters
  47     SSLContext sslContext;
  48     SSLParameters sslParams;
  49     int priority = -1;
  50 
  51     @Override
  52     public HttpClientBuilderImpl cookieHandler(CookieHandler cookieHandler) {
  53         requireNonNull(cookieHandler);
  54         this.cookieHandler = cookieHandler;
  55         return this;
  56     }
  57 








  58 
  59     @Override
  60     public HttpClientBuilderImpl sslContext(SSLContext sslContext) {
  61         requireNonNull(sslContext);
  62         this.sslContext = sslContext;
  63         return this;
  64     }
  65 
  66 
  67     @Override
  68     public HttpClientBuilderImpl sslParameters(SSLParameters sslParameters) {
  69         requireNonNull(sslParameters);
  70         this.sslParams = Utils.copySSLParameters(sslParameters);
  71         return this;
  72     }
  73 
  74 
  75     @Override
  76     public HttpClientBuilderImpl executor(Executor s) {
  77         requireNonNull(s);




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.internal.net.http;
  27 
  28 import java.net.Authenticator;
  29 import java.net.CookieHandler;
  30 import java.net.ProxySelector;
  31 import java.time.Duration;
  32 import java.util.concurrent.Executor;
  33 import javax.net.ssl.SSLContext;
  34 import javax.net.ssl.SSLParameters;
  35 import java.net.http.HttpClient;
  36 import jdk.internal.net.http.common.Utils;
  37 import static java.util.Objects.requireNonNull;
  38 
  39 public class HttpClientBuilderImpl implements HttpClient.Builder {
  40 
  41     CookieHandler cookieHandler;
  42     Duration connectTimeout;
  43     HttpClient.Redirect followRedirects;
  44     ProxySelector proxy;
  45     Authenticator authenticator;
  46     HttpClient.Version version;
  47     Executor executor;
  48     // Security parameters
  49     SSLContext sslContext;
  50     SSLParameters sslParams;
  51     int priority = -1;
  52 
  53     @Override
  54     public HttpClientBuilderImpl cookieHandler(CookieHandler cookieHandler) {
  55         requireNonNull(cookieHandler);
  56         this.cookieHandler = cookieHandler;
  57         return this;
  58     }
  59 
  60     @Override
  61     public HttpClientBuilderImpl connectTimeout(Duration duration) {
  62         requireNonNull(duration);
  63         if (duration.isNegative() || Duration.ZERO.equals(duration))
  64             throw new IllegalArgumentException("Invalid duration: " + duration);
  65         this.connectTimeout = duration;
  66         return this;
  67     }
  68 
  69     @Override
  70     public HttpClientBuilderImpl sslContext(SSLContext sslContext) {
  71         requireNonNull(sslContext);
  72         this.sslContext = sslContext;
  73         return this;
  74     }
  75 
  76 
  77     @Override
  78     public HttpClientBuilderImpl sslParameters(SSLParameters sslParameters) {
  79         requireNonNull(sslParameters);
  80         this.sslParams = Utils.copySSLParameters(sslParameters);
  81         return this;
  82     }
  83 
  84 
  85     @Override
  86     public HttpClientBuilderImpl executor(Executor s) {
  87         requireNonNull(s);


< prev index next >