1 /*
2 * Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 package com.amazonaws.http.conn;
17
18 import com.amazonaws.http.apache.utils.HttpContextUtils;
19 import org.apache.http.conn.socket.PlainConnectionSocketFactory;
20 import org.apache.http.protocol.HttpContext;
21
22 import java.io.IOException;
23 import java.net.Proxy;
24 import java.net.Socket;
25
26 /**
27 * Socket factory for creating plain (non TLS) connections.
28 */
29 public class SdkPlainSocketFactory extends PlainConnectionSocketFactory {
30 @Override
31 public Socket createSocket(HttpContext ctx) throws IOException {
32 if (HttpContextUtils.disableSocketProxy(ctx)) {
33 return new Socket(Proxy.NO_PROXY);
34 }
35 return super.createSocket(ctx);
36 }
37 }
38