You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2020/05/17 17:01:00 UTC

[GitHub] [httpcomponents-client] rafiek commented on a change in pull request #224: HTTPCLIENT-1966

rafiek commented on a change in pull request #224:
URL: https://github.com/apache/httpcomponents-client/pull/224#discussion_r426282600



##########
File path: httpclient/src/main/java/org/apache/http/conn/socket/SOCKSConnectionSocketFactory.java
##########
@@ -0,0 +1,88 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.conn.socket;
+
+import org.apache.http.HttpHost;
+import org.apache.http.annotation.Contract;
+import org.apache.http.annotation.ThreadingBehavior;
+import org.apache.http.protocol.HttpContext;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.Socket;
+
+/**
+ * The default class for creating plain (unencrypted) SOCKS sockets based on system properties 'socksProxyHost' and 'socksProxyPort'.
+ *
+ * @since 4.5
+ */
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class SOCKSConnectionSocketFactory implements ConnectionSocketFactory {
+
+    public static final SOCKSConnectionSocketFactory INSTANCE = new SOCKSConnectionSocketFactory();
+
+    public static SOCKSConnectionSocketFactory getSocketFactory() {
+        return INSTANCE;
+    }
+
+    public SOCKSConnectionSocketFactory() {
+        super();
+    }
+
+    @Override
+    public Socket createSocket(final HttpContext context) throws IOException {
+        final String socksProxyHost = System.getProperty("socksProxyHost");
+        final String socksProxyPort = System.getProperty("socksProxyPort");

Review comment:
       Indeed, how about:
   ```suggestion
           final String socksProxyPort = System.getProperty("socksProxyPort", "1080");
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org