[core-dev] http proxy auth

Eugene Romanenko <[email protected]> Wed, 27 Jul 2005 21:14:15 +0200
Newsgroups gmane.network.gnutella.limewire.core.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------030502090008090006000405
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Patch for http-proxy authorization, basic scheme.

-- 
Bye,
Eugene.    http://eros2.by.ru

--------------030502090008090006000405
Content-Type: text/plain;
 name="http-proxy-auth.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="http-proxy-auth.diff"

Index: core/com/limegroup/gnutella/util/Sockets.java
===================================================================
RCS file: /cvs/core/com/limegroup/gnutella/util/Sockets.java,v
retrieving revision 1.37
diff -u -w -b -B -r1.37 Sockets.java
--- core/com/limegroup/gnutella/util/Sockets.java	25 Jul 2005 17:07:17 -0000	1.37
+++ core/com/limegroup/gnutella/util/Sockets.java	27 Jul 2005 18:11:37 -0000
@@ -12,6 +12,8 @@
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 
+import org.apache.commons.httpclient.util.Base64;
+
 import com.limegroup.gnutella.ByteReader;
 import com.limegroup.gnutella.settings.ConnectionSettings;
 
@@ -324,7 +326,16 @@
 		throws IOException {
 		    
 		String connectString =
-			"CONNECT " + host + ":" + port + " HTTP/1.0\r\n\r\n";
+			"CONNECT " + host + ":" + port + " HTTP/1.0\r\n";
+
+		if (ConnectionSettings.PROXY_AUTHENTICATE.getValue()) {
+			String username = ConnectionSettings.PROXY_USERNAME.getValue();
+			String password = ConnectionSettings.PROXY_PASS.getValue();
+			String toEncode = username + ":" + password;
+			String encoded = new String( Base64.encode( toEncode.getBytes() ) );
+			connectString += ( "Proxy-Authorization: Basic " + encoded + "\r\n" );
+		}
+		connectString += "\r\n";
 
 		String proxyHost = ConnectionSettings.PROXY_HOST.getValue();
 		int proxyPort = ConnectionSettings.PROXY_PORT.getValue();

--------------030502090008090006000405
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
core-dev mailing list
[email protected]
http://www.limewire.org/mailman/listinfo/core-dev

--------------030502090008090006000405--