You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by al so <vo...@gmail.com> on 2012/08/23 16:02:56 UTC

http proxy API

<Subject changed to reflect the contents>

> Is there an API that can perform some diagnostics to verify the http proxy
> configuration:
>
>  some thing like: boolean verifyProxyConfiguration(hostname, port,
> basicAuth, username, passwd)
>
>  This method would do http  CONNECT handshake with the proxy and returns
> success/failure. It would be be nice to capture any error message as well.
>
>

RE: http proxy API

Posted by Martin Gainty <mg...@hotmail.com>.
DIRECT



          Represents a direct connection, or the absence of a proxy.


HTTP



          Represents proxy for high level protocols such as HTTP or FTP.


SOCKS



          Represents a SOCKS (V4 or V5) proxy.
//in your case since you need to authentication via username and proxy you'll want to specify SOCKS
//then Generating a proxy you will need 2 parameters Proxy.Type which is SOCKS  and

//then generate a SocketAddress
InetSocketAddress(String hostname,
                  int port)

for your 2nd parameter SocketAddress

public Proxy(Proxy.Type type,
             SocketAddress sa)

Now you finally have a non-null valid Proxy object which is supplied as the parameter to URL.openConnection
then openConnection thru the proxy to the existing URL object is described at

http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URL.html#openConnection%28java.net.Proxy%29




You're going to need 
catch(IoException exp)
so Be aware of timeout issues as you need to establish a Socket connection thru the Proxy 
http://www.docjar.com/html/api/org/apache/harmony/luni/net/PlainSocketImpl.java.html

//if you're getting IOExceptions you're going to have to need to create a object of SocketImpl with a proxy
http://www.docjar.com/html/api/org/apache/harmony/luni/net/PlainSocketImpl.java.html
 public PlainSocketImpl(Proxy proxy) {
    }

//then connecting with specific SocketOptions.SO_TIMEOUT
public void setOption(int optID, Object val) throws SocketException {
  318           if (optID == SocketOptions.SO_TIMEOUT) {

//then connecting using a specific timeout parameter
/**
  218        * Connects this socket to the specified remote host address/port.
  219        * 
  220        * @param anAddr
  221        *            the remote host address to connect to
  222        * @param aPort
  223        *            the remote port to connect to
  224        * @param timeout
  225        *            a timeout where supported. 0 means no timeout
  226        * @throws IOException
  227        *             if an error occurs while connecting
  228        */
  229       private void connect(InetAddress anAddr, int aPort, int timeout)
  230               throws IOException {

HTH,
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.


> Date: Thu, 23 Aug 2012 07:02:56 -0700
> Subject: http proxy API
> From: volkswak@gmail.com
> To: user@commons.apache.org
> 
> <Subject changed to reflect the contents>
> 
> > Is there an API that can perform some diagnostics to verify the http proxy
> > configuration:
> >
> >  some thing like: boolean verifyProxyConfiguration(hostname, port,
> > basicAuth, username, passwd)
> >
> >  This method would do http  CONNECT handshake with the proxy and returns
> > success/failure. It would be be nice to capture any error message as well.
> >
> >