Android Open Source - Orlib Socks Http Client






From Project

Back to project page Orlib.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project Orlib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package info.guardianproject.net.http;
//w  w  w  . j  a  v  a 2  s .c o m
import info.guardianproject.net.SocksSocketFactory;

import java.net.Proxy;
import java.net.UnknownHostException;

import org.apache.http.HttpVersion;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;

public class SocksHttpClient extends DefaultHttpClient {

  private final static String DEFAULT_HOST = "localhost";
  private final static int DEFAULT_PORT = 9050;
  
  private static ClientConnectionManager ccm = null;
  private static HttpParams params = null;
  
  public SocksHttpClient () throws UnknownHostException
  {
    
       super(initConnectionManager(DEFAULT_HOST, DEFAULT_PORT), initParams());
      
       
  }
  
  public SocksHttpClient (String host, int port) throws UnknownHostException
  {
    
       super(initConnectionManager(host, port), initParams());
  
       
  }
  
  
  private static ClientConnectionManager initConnectionManager (String proxyHost, int proxyPort) throws UnknownHostException
  {
    if (ccm == null)
    {
      
    
    SchemeRegistry supportedSchemes = new SchemeRegistry();
    
     supportedSchemes.register(new Scheme("http", 
                  SocksSocketFactory.getSocketFactory(proxyHost, proxyPort), 80));
      
     supportedSchemes.register(new Scheme("https", 
                  ModSSLSocketFactory.getSocketFactory(Proxy.Type.SOCKS, proxyHost, proxyPort), 443));
  
     
      ccm = new MyThreadSafeClientConnManager(initParams(), supportedSchemes);
    }
    
      return ccm;
  }
  
  private static HttpParams initParams ()
  {
      if (params == null)
      {
        // prepare parameters
        params = new BasicHttpParams();
   //     HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
//        HttpProtocolParams.setContentCharset(params, "UTF-8");
  //      HttpProtocolParams.setUseExpectContinue(params, true);
      }
      
      return params;
  }
}




Java Source Code List

info.guardianproject.net.SocksSocketFactory.java
info.guardianproject.net.http.HttpManager.java
info.guardianproject.net.http.ModSSLSocketFactory.java
info.guardianproject.net.http.MyDefaultClientConnectionOperator.java
info.guardianproject.net.http.MyThreadSafeClientConnManager.java
info.guardianproject.net.http.SocksHttpClient.java
net.sourceforge.jsocks.SOCKS.java
net.sourceforge.jsocks.SocksServerException.java
net.sourceforge.jsocks.socks.AuthenticationException.java
net.sourceforge.jsocks.socks.AuthenticationNone.java
net.sourceforge.jsocks.socks.Authentication.java
net.sourceforge.jsocks.socks.InetRange.java
net.sourceforge.jsocks.socks.ProxyMessage.java
net.sourceforge.jsocks.socks.ProxyServer.java
net.sourceforge.jsocks.socks.Proxy.java
net.sourceforge.jsocks.socks.Socks4Message.java
net.sourceforge.jsocks.socks.Socks4Proxy.java
net.sourceforge.jsocks.socks.Socks5DatagramSocket.java
net.sourceforge.jsocks.socks.Socks5Message.java
net.sourceforge.jsocks.socks.Socks5Proxy.java
net.sourceforge.jsocks.socks.SocksException.java
net.sourceforge.jsocks.socks.SocksServerSocket.java
net.sourceforge.jsocks.socks.SocksSocket.java
net.sourceforge.jsocks.socks.UDPEncapsulation.java
net.sourceforge.jsocks.socks.UDPRelayServer.java
net.sourceforge.jsocks.socks.UserPasswordAuthentication.java
net.sourceforge.jsocks.socks.server.IdentAuthenticator.java
net.sourceforge.jsocks.socks.server.Ident.java
net.sourceforge.jsocks.socks.server.ServerAuthenticatorNone.java
net.sourceforge.jsocks.socks.server.ServerAuthenticator.java
net.sourceforge.jsocks.socks.server.UserPasswordAuthenticator.java
net.sourceforge.jsocks.socks.server.UserValidation.java
orlib.sample.OrlibMainActivity.java