to.etc.net
Class MultipartPoster

java.lang.Object
  extended by to.etc.net.MultipartPoster

Deprecated.

@Deprecated
public class MultipartPoster
extends java.lang.Object

This class allows posting a multipart/form-data request to a server. It uses an URL as the base to connect to, and it has methods to add parameters and files to the set to send.

This class uses a lazy mechanism to get file data to write for posted files: when data is required for a file parameter it repeatedly calls a handler for a given parameter.

First create an instance of this class. Then add all parameters to PUT using the addParam() and addFile() calls. When all parameters to put have been set then call issue() to exchange the request.

The call to issue returns the connection that is used to send the request; you need to read the response stream yourself (by calling getInputStream() and reading it) since I have NO idea what you want to do with the answer ;-)

This structure can be reused by calling clear() before use, which clears all parameters and files set.

Author:
Frits Jalvingh

Constructor Summary
MultipartPoster()
          Deprecated.  
 
Method Summary
 void addFile(java.lang.String name, java.lang.String fname, java.io.File f)
          Deprecated. Adds a file parameter to the request.
 void addFile(java.lang.String name, java.lang.String fname, java.io.InputStream is, int len)
          Deprecated. Adds a file to send to the request.
 void addFile(java.lang.String name, java.lang.String fname, MultipartFile mf)
          Deprecated. Adds a file parameter to the request.
 void addParam(java.lang.String name, java.lang.String value)
          Deprecated. Adds a parameter to send to the http server.
 void clear()
          Deprecated. Removes all parameters currently in the table.
 void clearProxyAuthentication()
          Deprecated.  
 java.net.HttpURLConnection exchange(java.net.URL url)
          Deprecated. Sends the constructed request to the server, and returns the reply stream (the output file generated by the server).
 void setListener(MultipartSendListener mpsl)
          Deprecated.  
 void setProxyAuthentication(java.lang.String auth)
          Deprecated.  
 void setProxyAuthentication(java.lang.String uid, java.lang.String pw)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipartPoster

public MultipartPoster()
Deprecated. 
Method Detail

setProxyAuthentication

public void setProxyAuthentication(java.lang.String auth)
Deprecated. 

setProxyAuthentication

public void setProxyAuthentication(java.lang.String uid,
                                   java.lang.String pw)
Deprecated. 

clearProxyAuthentication

public void clearProxyAuthentication()
Deprecated. 

setListener

public void setListener(MultipartSendListener mpsl)
Deprecated. 

clear

public void clear()
Deprecated. 
Removes all parameters currently in the table. It does NOT call close for files that were added but unused!


addParam

public void addParam(java.lang.String name,
                     java.lang.String value)
Deprecated. 
Adds a parameter to send to the http server. The parameter is encoded using UTF-8 encoding. You can add the same name multiple times; each parameter will be put to the server.

Parameters:
name - the parameter's name
value - the parameter's value.

addFile

public void addFile(java.lang.String name,
                    java.lang.String fname,
                    MultipartFile mf)
Deprecated. 
Adds a file parameter to the request. The MultipartFile class will provide the file's data as soon as it is needed when sending.

Parameters:
name - the parameter's name.
fname - the suggested filename
mf - the handler which will provide the file's data as soon as it is needed.

addFile

public void addFile(java.lang.String name,
                    java.lang.String fname,
                    java.io.File f)
Deprecated. 
Adds a file parameter to the request. The file will be read as soon as the data is needed.

Parameters:
name - the name of the parameter
fname - the suggested filename
f - the existing file to send

addFile

public void addFile(java.lang.String name,
                    java.lang.String fname,
                    java.io.InputStream is,
                    int len)
Deprecated. 
Adds a file to send to the request. The data is read from the stream provided. You must close the stream yourself!!

Parameters:
name - the name of the parameter.
fname - the suggested filename
is - the stream providing the data.

exchange

public java.net.HttpURLConnection exchange(java.net.URL url)
                                    throws java.lang.Exception
Deprecated. 
Sends the constructed request to the server, and returns the reply stream (the output file generated by the server).

Parameters:
conn - the URL to post the data to,
Returns:
Throws:
java.lang.Exception - on any error.