commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <>
Subject RE: http proxy API
Date Thu, 23 Aug 2012 17:55:02 GMT


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


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


          Represents a SOCKS (V4 or V5) proxy.
//in your case since you need to authentication via username and proxy you'll want to specify
//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

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

//if you're getting IOExceptions you're going to have to need to create a object of SocketImpl
with a proxy
 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 {

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:
> To:
> <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.
> >
> >

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message