1c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath/*
2c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  Licensed to the Apache Software Foundation (ASF) under one or more
3c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  contributor license agreements.  See the NOTICE file distributed with
4c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  this work for additional information regarding copyright ownership.
5c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  The ASF licenses this file to You under the Apache License, Version 2.0
6c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  (the "License"); you may not use this file except in compliance with
7c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  the License.  You may obtain a copy of the License at
8c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *
9c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *     http://www.apache.org/licenses/LICENSE-2.0
10c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *
11c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  Unless required by applicable law or agreed to in writing, software
12c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  distributed under the License is distributed on an "AS IS" BASIS,
13c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  See the License for the specific language governing permissions and
15c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath *  limitations under the License.
16c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath */
17c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath
182231db3e6bb54447a9b14cf004a6cb03c373651cjwilsonpackage com.squareup.okhttp;
19c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath
20c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamathimport java.io.IOException;
21c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamathimport java.net.Proxy;
22c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamathimport java.net.URL;
23c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamathimport java.net.URLConnection;
24c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamathimport java.net.URLStreamHandler;
25c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath
26c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamathpublic final class HttpsHandler extends URLStreamHandler {
27c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath    @Override protected URLConnection openConnection(URL url) throws IOException {
282231db3e6bb54447a9b14cf004a6cb03c373651cjwilson        return new OkHttpClient().open(url);
29c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath    }
30c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath
31c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath    @Override protected URLConnection openConnection(URL url, Proxy proxy) throws IOException {
32c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath        if (url == null || proxy == null) {
33c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath            throw new IllegalArgumentException("url == null || proxy == null");
34c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath        }
352231db3e6bb54447a9b14cf004a6cb03c373651cjwilson        return new OkHttpClient().setProxy(proxy).open(url);
36c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath    }
37c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath
38c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath    @Override protected int getDefaultPort() {
39c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath        return 443;
40c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath    }
41c3f6f16bd4a2338e88275641b9f2f56e816ca377Narayan Kamath}
42