public class MultipartFormPost extends Object
Constructor and Description |
---|
MultipartFormPost(String urlString)
Creates a new multipart POST HTTP request for a specified URL string
|
MultipartFormPost(URL url)
Creates a new multipart POST HTTP request for a specified URL
|
Modifier and Type | Method and Description |
---|---|
int |
getBufferSize() |
protected URLConnection |
getConnection(int contentLength) |
protected void |
newline() |
InputStream |
post()
posts the requests to the server, with all the cookies and parameters
that were added
|
InputStream |
post(Map<String,Object> parameters)
posts the requests to the server, with all the cookies and parameters
that were added before (if any), and with parameters that are passed in
the argument
|
InputStream |
post(Map<String,String> cookies,
Map<String,Object> parameters)
posts the requests to the server, with all the cookies and parameters
that were added before (if any), and with cookies and parameters that are
passed in the arguments
|
InputStream |
post(Object[] parameters)
posts the requests to the server, with all the cookies and parameters
that were added before (if any), and with parameters that are passed in
the argument
|
InputStream |
post(String[] cookies,
Object[] parameters)
posts the requests to the server, with all the cookies and parameters
that were added before (if any), and with cookies and parameters that are
passed in the arguments
|
InputStream |
post(String name,
Object value)
post the POST request to the server, with the specified parameter
|
InputStream |
post(String name1,
Object value1,
String name2,
Object value2)
post the POST request to the server, with the specified parameters
|
InputStream |
post(String name1,
Object value1,
String name2,
Object value2,
String name3,
Object value3)
post the POST request to the server, with the specified parameters
|
InputStream |
post(String name1,
Object value1,
String name2,
Object value2,
String name3,
Object value3,
String name4,
Object value4)
post the POST request to the server, with the specified parameters
|
static InputStream |
post(URL url,
Map<String,Object> parameters)
posts a new request to specified URL, with parameters that are passed in
the argument
|
static InputStream |
post(URL url,
Map<String,String> cookies,
Map<String,Object> parameters)
posts a new request to specified URL, with cookies and parameters that
are passed in the argument
|
static InputStream |
post(URL url,
Object[] parameters)
posts a new request to specified URL, with parameters that are passed in
the argument
|
static InputStream |
post(URL url,
String[] cookies,
Object[] parameters)
posts a new request to specified URL, with cookies and parameters that
are passed in the argument
|
static InputStream |
post(URL url,
String name1,
Object value1)
post the POST request specified URL, with the specified parameter
|
static InputStream |
post(URL url,
String name1,
Object value1,
String name2,
Object value2)
post the POST request to specified URL, with the specified parameters
|
static InputStream |
post(URL url,
String name1,
Object value1,
String name2,
Object value2,
String name3,
Object value3)
post the POST request to specified URL, with the specified parameters
|
static InputStream |
post(URL url,
String name1,
Object value1,
String name2,
Object value2,
String name3,
Object value3,
String name4,
Object value4)
post the POST request to specified URL, with the specified parameters
|
protected static String |
randomString() |
void |
setBufferSize(int bufferSize)
Defines size of the buffer chunk (in bytes) used to conduct
transfer with.
|
void |
setCookie(String name,
String value)
adds a cookie to the requst
|
void |
setCookies(Map<String,String> cookies)
adds cookies to the request
|
void |
setCookies(String[] cookies)
adds cookies to the request
|
void |
setKiller(ExportAbortInformer killer)
Set this if you want to be able to abort the transfer.
|
void |
setParameter(String name,
File file)
adds a file parameter to the request
|
void |
setParameter(String name,
Object object)
adds a parameter to the request; if the parameter is a File, the file is
uploaded, otherwise the string value of the parameter is passed in the
request
|
void |
setParameter(String name,
String value)
adds a string parameter to the request
|
void |
setParameter(String name,
String filename,
byte[] bytes) |
void |
setParameter(String name,
String filename,
InputStream is)
adds a file parameter to the request
|
void |
setParameters(Map<String,Object> parameters)
adds parameters to the request
|
void |
setParameters(Object[] parameters)
adds parameters to the request
|
void |
setPassword(String password) |
void |
setProgressListener(ExportProgressMonitor progressListener)
Set this if you want to be notified of transfer progress.
|
void |
setUserId(String userId) |
protected void |
write(char c) |
protected void |
write(String s) |
protected void |
writeln(String s) |
public MultipartFormPost(URL url)
url
- the URL to send request toException
public MultipartFormPost(String urlString) throws MalformedURLException
urlString
- the string representation of the URL to send request toException
MalformedURLException
protected URLConnection getConnection(int contentLength) throws Exception
Exception
public void setUserId(String userId)
public void setPassword(String password)
protected static String randomString()
public void setProgressListener(ExportProgressMonitor progressListener)
progressListener
- progress callbackpublic void setKiller(ExportAbortInformer killer)
killer
- public void setCookie(String name, String value) throws Exception
name
- cookie namevalue
- cookie valueException
public void setCookies(Map<String,String> cookies) throws Exception
cookies
- the cookie "name-to-value" mapException
public void setCookies(String[] cookies) throws Exception
cookies
- array of cookie names and values (cookies[2*i] is a name,
cookies[2*i + 1] is a value)Exception
public void setParameter(String name, String value) throws Exception
name
- parameter namevalue
- parameter valueException
public int getBufferSize()
public void setBufferSize(int bufferSize)
bufferSize
- public void setParameter(String name, String filename, InputStream is) throws Exception
name
- parameter namefilename
- the name of the fileis
- input stream to read the contents of the file fromException
public void setParameter(String name, String filename, byte[] bytes) throws Exception
name
- filename
- bytes
- content of the fileException
public void setParameter(String name, File file) throws Exception
name
- parameter namefile
- the file to uploadException
public void setParameter(String name, Object object) throws Exception
name
- parameter nameobject
- parameter value, a File or anything else that can be
stringifiedException
public void setParameters(Map<String,Object> parameters) throws Exception
parameters
- "name-to-value" map of parameters; if a value is a file, the
file is uploaded, otherwise it is stringified and sent in the
requestException
public void setParameters(Object[] parameters) throws Exception
parameters
- array of parameter names and values (parameters[2*i] is a
name, parameters[2*i + 1] is a value); if a value is a file,
the file is uploaded, otherwise it is stringified and sent in
the requestException
public InputStream post() throws Exception
Exception
public InputStream post(Map<String,Object> parameters) throws Exception
parameters
- request parametersException
setParameters
public InputStream post(Object[] parameters) throws Exception
parameters
- request parametersException
setParameters
public InputStream post(Map<String,String> cookies, Map<String,Object> parameters) throws Exception
cookies
- request cookiesparameters
- request parametersException
setParameters
,
setCookies
public InputStream post(String[] cookies, Object[] parameters) throws Exception
cookies
- request cookiesparameters
- request parametersException
setParameters
,
setCookies
public InputStream post(String name, Object value) throws Exception
name
- parameter namevalue
- parameter valueException
setParameter
public InputStream post(String name1, Object value1, String name2, Object value2) throws Exception
name1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter valueException
setParameter
public InputStream post(String name1, Object value1, String name2, Object value2, String name3, Object value3) throws Exception
name1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter valuename3
- third parameter namevalue3
- third parameter valueException
setParameter
public InputStream post(String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) throws Exception
name1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter valuename3
- third parameter namevalue3
- third parameter valuename4
- fourth parameter namevalue4
- fourth parameter valueException
setParameter
public static InputStream post(URL url, Map<String,Object> parameters) throws Exception
parameters
- request parametersException
setParameters
public static InputStream post(URL url, Object[] parameters) throws Exception
parameters
- request parametersException
setParameters
public static InputStream post(URL url, Map<String,String> cookies, Map<String,Object> parameters) throws Exception
cookies
- request cookiesparameters
- request parametersException
setCookies
,
setParameters
public static InputStream post(URL url, String[] cookies, Object[] parameters) throws Exception
cookies
- request cookiesparameters
- request parametersException
setCookies
,
setParameters
public static InputStream post(URL url, String name1, Object value1) throws Exception
name
- parameter namevalue
- parameter valueException
setParameter
public static InputStream post(URL url, String name1, Object value1, String name2, Object value2) throws Exception
name1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter valueException
setParameter
public static InputStream post(URL url, String name1, Object value1, String name2, Object value2, String name3, Object value3) throws Exception
name1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter valuename3
- third parameter namevalue3
- third parameter valueException
setParameter
public static InputStream post(URL url, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) throws Exception
name1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter valuename3
- third parameter namevalue3
- third parameter valuename4
- fourth parameter namevalue4
- fourth parameter valueException
setParameter
Copyright © 2012-2013 Bambi Software Foundation. All Rights Reserved.