jfileupload.transfer.client.http
Class HTTPTransfer

java.lang.Object
  extended by jfileupload.transfer.client.core.AbstractTransferController
      extended by jfileupload.transfer.client.http.HTTPTransfer
All Implemented Interfaces:
TransferController
Direct Known Subclasses:
HTTPUploadTransfer

public abstract class HTTPTransfer
extends AbstractTransferController

This class implements a TransferController for HTTP protocol. It relies on Commons-HTTPClient 3.x.


Nested Class Summary
 
Nested classes/interfaces inherited from class jfileupload.transfer.client.core.AbstractTransferController
AbstractTransferController.HeadInfo
 
Field Summary
static java.lang.String CONTENTRANGE
           
static java.lang.String COOKIECLEAR
           
static java.lang.String COOKIEHEADER
           
static java.lang.String COOKIENAME
           
static java.lang.String COOKIEOVERWRITE
           
static java.lang.String COOKIEPATH
           
static java.lang.String COOKIESOURCE
           
static java.lang.String COOKIEVALUE
           
static java.lang.String DEPRECATEDURL
           
static java.lang.String ERRORHEADER
           
static java.lang.String HTTPAUTHMETHOD
           
static java.lang.String HTTPNTLMDOMAIN
           
static java.lang.String HTTPNTLMHOST
           
static java.lang.String HTTPPROXYHOST
           
static java.lang.String HTTPPROXYNTLMDOMAIN
           
static java.lang.String HTTPPROXYNTLMHOST
           
static java.lang.String HTTPPROXYPASSWORD
           
static java.lang.String HTTPPROXYPORT
           
static java.lang.String HTTPPROXYUSERNAME
           
static java.lang.String MIMETYPES
           
static java.lang.String STATUSCODEKEY
           
static java.lang.String WEAKSSL
           
 
Fields inherited from class jfileupload.transfer.client.core.AbstractTransferController
BUFFERSIZE, GZIPEXTENSION, ZIPEXTENSION
 
Fields inherited from interface jfileupload.transfer.client.core.TransferController
COMPLETED_STATUS, MAX_AUTH_ATTEMPTS, PREPROCESSING_FILTER, RUNNING_STATUS, WAITING_STATUS
 
Constructor Summary
HTTPTransfer()
          HTTP implementation.
 
Method Summary
 void authenticate()
          Send an HTTP request to "url" parameter and prompt for authentication if needed.
protected  void autoDetectProxy(java.net.URL url)
          Try to auto-detect proxy settings.
abstract  void begin()
          Fix issue for HTTP port with "_" in hostname.
abstract  void cancel()
          Cancel transfer.
abstract  java.lang.Object execute()
          Start synchronous transfer.
 org.apache.commons.httpclient.HttpClient getClient()
          Return HttpClient instance.
 CustomFileNameMap getCustomFilenameMap()
          Return custom mime types.
 java.util.HashMap getCustomParameters()
          Return HTTP custom parameters.
 java.lang.String getHostname()
          Return hostname.
 java.util.Map headInfo(java.lang.String url, java.util.Map headers, boolean mkcol)
          Process a HEAD/MKCOL request with incoming headers and returns response headers.
 void init()
          Inits HTTP transfer (Proxy, SSL Factory, Cookies, Concurrency ...)
protected  org.apache.commons.httpclient.Cookie loadCookie(java.lang.String p, java.lang.String v, java.util.TreeMap cookieMap)
          Load cookienameX/cookievalueX/cookiepathX.
protected  java.util.TreeMap loadCookiesFromHandler(java.net.URL url)
          Loads cookies from CookieHandler (if available).
protected  void parseAuthenticateHeader(org.apache.commons.httpclient.Header header, AuthenticationModel model)
          Parse WWW-Authentication or Proxy-Authentication headers.
 void registerSSLSocketFactory()
          Register a custom SSL socket factory.
protected  void setProxyAuthentication(java.util.HashMap p)
          Set Proxy-Authentication
protected  void setupCookies(org.apache.commons.httpclient.HttpClient clt, java.util.TreeMap cookieMap)
          Setup cookies.
protected  void setWWWAuthentication(java.util.HashMap p)
          Set Basic WWW-Authentication.
 
Methods inherited from class jfileupload.transfer.client.core.AbstractTransferController
addChecksumListener, addCompressListener, addFilterListener, addProtocolListener, addSplitListener, addTransferListener, authenticate, checksumCompletedNotification, checksumFailedNotification, checksummingNotification, checksumStartedNotification, checkZipMaxSize, cleanFilter, cleanFilter, compress, compress, compressFolder, compressingNotification, compressionFailedNotification, computeChecksum, executeFilter, executeFilter, getAllowedSourceFiles, getAuthentication, getBlackList, getChecksumListeners, getChunks, getChunkSize, getCompressListeners, getCRC32, getEncoding, getExt, getFilter, getFilter, getFilterChain, getFilterIDs, getFilterImpl, getFilterImpl, getFilterListeners, getFullMaxSize, getHidden, getLastChunkSize, getLong, getMaxDepth, getMaxFiles, getMaxSize, getMD5, getMetaProperties, getMetaScope, getMinSize, getOverwrite, getOverwriteWarn, getParameters, getParamFile, getParentContainer, getPassword, getPolicy, getPreemptiveAuth, getPreProcessingFilter, getPreProcessingFilterImpl, getProtocolListeners, getRawConf, getResume, getResumeOffset, getRetry, getRetryDelay, getRootDir, getServerUrl, getSource, getSplitListeners, getStatus, getTarget, getTemplate, getTemplateScope, getTimeOut, getTmpDir, getTmpFolder, getTransferFileFilter, getTransferListeners, getUsername, getWhiteList, getZipFolder, getZipIgnoreList, getZipMaxSize, getZipOnFly, hexDump, isAllowed, isThreaded, recurse, recursiveCompress, removeChecksumListener, removeCompressListener, removeFilterListener, removeProtocolListener, removeSplitListener, removeTransferListener, rename, setAuthentication, setBlackList, setChunkSize, setEncoding, setExt, setFilter, setFilter, setFilterChain, setFilterIDs, setFilterImpl, setFilterImpl, setFullMaxSize, setHidden, setMaxDepth, setMaxFiles, setMaxSize, setMetaProperties, setMetaScope, setMinSize, setOverwrite, setOverwriteWarn, setParameters, setParamFile, setParentContainer, setPassword, setPolicy, setPreemptiveAuth, setPreProcessingFilter, setPreProcessingFilterImpl, setRawConf, setResume, setResumeOffset, setRetry, setRetryDelay, setRootDir, setServerUrl, setSource, setStatus, setTarget, setTemplate, setTemplateScope, setThreaded, setTimeOut, setTmpDir, setUsername, setWhiteList, setZipFolder, setZipIgnoreList, setZipMaxSize, setZipOnFly, warnOverwrite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENTRANGE

public static final java.lang.String CONTENTRANGE
See Also:
Constant Field Values

COOKIENAME

public static java.lang.String COOKIENAME

COOKIEPATH

public static java.lang.String COOKIEPATH

COOKIEVALUE

public static java.lang.String COOKIEVALUE

COOKIEOVERWRITE

public static java.lang.String COOKIEOVERWRITE

COOKIECLEAR

public static java.lang.String COOKIECLEAR

COOKIEHEADER

public static java.lang.String COOKIEHEADER

COOKIESOURCE

public static java.lang.String COOKIESOURCE

MIMETYPES

public static java.lang.String MIMETYPES

ERRORHEADER

public static java.lang.String ERRORHEADER

HTTPPROXYHOST

public static java.lang.String HTTPPROXYHOST

HTTPPROXYPORT

public static java.lang.String HTTPPROXYPORT

HTTPPROXYUSERNAME

public static java.lang.String HTTPPROXYUSERNAME

HTTPPROXYPASSWORD

public static java.lang.String HTTPPROXYPASSWORD

HTTPPROXYNTLMHOST

public static java.lang.String HTTPPROXYNTLMHOST

HTTPPROXYNTLMDOMAIN

public static java.lang.String HTTPPROXYNTLMDOMAIN

HTTPNTLMHOST

public static java.lang.String HTTPNTLMHOST

HTTPNTLMDOMAIN

public static java.lang.String HTTPNTLMDOMAIN

HTTPAUTHMETHOD

public static java.lang.String HTTPAUTHMETHOD

WEAKSSL

public static java.lang.String WEAKSSL

DEPRECATEDURL

public static java.lang.String DEPRECATEDURL

STATUSCODEKEY

public static java.lang.String STATUSCODEKEY
Constructor Detail

HTTPTransfer

public HTTPTransfer()
HTTP implementation.

Method Detail

init

public void init()
          throws ClientException
Inits HTTP transfer (Proxy, SSL Factory, Cookies, Concurrency ...)

Specified by:
init in interface TransferController
Overrides:
init in class AbstractTransferController
Throws:
ClientException

setupCookies

protected void setupCookies(org.apache.commons.httpclient.HttpClient clt,
                            java.util.TreeMap cookieMap)
Setup cookies.

Parameters:
cookieMap -

loadCookie

protected org.apache.commons.httpclient.Cookie loadCookie(java.lang.String p,
                                                          java.lang.String v,
                                                          java.util.TreeMap cookieMap)
Load cookienameX/cookievalueX/cookiepathX.

Parameters:
p -
v -
cookieMap -
Returns:

loadCookiesFromHandler

protected java.util.TreeMap loadCookiesFromHandler(java.net.URL url)
Loads cookies from CookieHandler (if available).

Parameters:
url -
Returns:

registerSSLSocketFactory

public void registerSSLSocketFactory()
Register a custom SSL socket factory.


autoDetectProxy

protected void autoDetectProxy(java.net.URL url)
Try to auto-detect proxy settings.

Parameters:
url -

getHostname

public java.lang.String getHostname()
Return hostname.

Returns:

headInfo

public java.util.Map headInfo(java.lang.String url,
                              java.util.Map headers,
                              boolean mkcol)
                       throws ClientException
Process a HEAD/MKCOL request with incoming headers and returns response headers.

Parameters:
url -
headers -
mkcol -
Returns:
Throws:
ClientException

authenticate

public void authenticate()
Send an HTTP request to "url" parameter and prompt for authentication if needed. The request is an HTTP HEAD (or GET depending on httpauthmethod extra parameter). It's better than sending the full file and wait for unauthorized response. It checks for 407 and 401 responses to display proxy or www authentication prompt.


parseAuthenticateHeader

protected void parseAuthenticateHeader(org.apache.commons.httpclient.Header header,
                                       AuthenticationModel model)
Parse WWW-Authentication or Proxy-Authentication headers.

Parameters:
header -
model -

setWWWAuthentication

protected void setWWWAuthentication(java.util.HashMap p)
Set Basic WWW-Authentication.


setProxyAuthentication

protected void setProxyAuthentication(java.util.HashMap p)
Set Proxy-Authentication


getCustomParameters

public java.util.HashMap getCustomParameters()
Return HTTP custom parameters.

Returns:

getCustomFilenameMap

public CustomFileNameMap getCustomFilenameMap()
Return custom mime types.

Returns:

getClient

public org.apache.commons.httpclient.HttpClient getClient()
Return HttpClient instance.

Returns:

begin

public abstract void begin()
Fix issue for HTTP port with "_" in hostname.

Specified by:
begin in interface TransferController
Specified by:
begin in class AbstractTransferController

cancel

public abstract void cancel()
Description copied from interface: TransferController
Cancel transfer.

Specified by:
cancel in interface TransferController
Specified by:
cancel in class AbstractTransferController

execute

public abstract java.lang.Object execute()
                                  throws ClientException
Description copied from interface: TransferController
Start synchronous transfer.

Specified by:
execute in interface TransferController
Specified by:
execute in class AbstractTransferController
Throws:
ClientException