wjhk.jupload2.upload
Class HttpConnect

java.lang.Object
  extended by wjhk.jupload2.upload.HttpConnect

public class HttpConnect
extends Object

This class implements the task of connecting to a HTTP(S) url using a proxy.

Author:
felfert

Constructor Summary
HttpConnect(UploadPolicy policy)
          Creates a new instance.
 
Method Summary
 Socket Connect(URL url)
          Connects to a given URL automatically using a proxy.
 Socket Connect(URL url, Proxy proxy)
          Connects to a given URL.
 String getProtocol()
          Retrieve the protocol to be used for the postURL of the current policy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpConnect

public HttpConnect(UploadPolicy policy)
Creates a new instance.

Parameters:
policy - The UploadPolicy to be used for logging.
Method Detail

Connect

public Socket Connect(URL url,
                      Proxy proxy)
               throws NoSuchAlgorithmException,
                      KeyManagementException,
                      ConnectException,
                      UnknownHostException,
                      IOException,
                      KeyStoreException,
                      CertificateException,
                      IllegalArgumentException,
                      UnrecoverableKeyException
Connects to a given URL.

Parameters:
url - The URL to connect to
proxy - The proxy to be used, may be null if direct connection is needed
Returns:
A socket, connected to the specified URL. May be null if an error occurs.
Throws:
NoSuchAlgorithmException
KeyManagementException
IOException
UnknownHostException
ConnectException
CertificateException
KeyStoreException
UnrecoverableKeyException
IllegalArgumentException

Connect

public Socket Connect(URL url)
               throws NoSuchAlgorithmException,
                      KeyManagementException,
                      ConnectException,
                      UnknownHostException,
                      IOException,
                      URISyntaxException,
                      KeyStoreException,
                      CertificateException,
                      IllegalArgumentException,
                      UnrecoverableKeyException
Connects to a given URL automatically using a proxy.

Parameters:
url - The URL to connect to
Returns:
A socket, connected to the specified URL. May be null if an error occurs.
Throws:
NoSuchAlgorithmException
KeyManagementException
IOException
UnknownHostException
ConnectException
URISyntaxException
UnrecoverableKeyException
CertificateException
KeyStoreException
UnrecoverableKeyException
IllegalArgumentException

getProtocol

public String getProtocol()
                   throws URISyntaxException,
                          KeyManagementException,
                          NoSuchAlgorithmException,
                          UnknownHostException,
                          KeyStoreException,
                          CertificateException,
                          IllegalArgumentException,
                          UnrecoverableKeyException,
                          IOException,
                          JUploadException
Retrieve the protocol to be used for the postURL of the current policy. This method issues a HEAD request to the postURL and then examines the protocol version returned in the response.

Returns:
The string, describing the protocol (e.g. "HTTP/1.1")
Throws:
URISyntaxException
IOException
UnrecoverableKeyException
IllegalArgumentException
CertificateException
KeyStoreException
UnknownHostException
NoSuchAlgorithmException
KeyManagementException
JUploadException