|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Facemorph.ClientHttpRequest
public class ClientHttpRequest
Title: Client HTTP Request class
Description: this class helps to send POST HTTP requests with various form data, including files. Cookies can be added to be included in the request.
Constructor Summary | |
---|---|
ClientHttpRequest(java.lang.String urlString)
Creates a new multipart POST HTTP request for a specified URL string |
|
ClientHttpRequest(java.net.URL url)
Creates a new multipart POST HTTP request for a specified URL |
|
ClientHttpRequest(java.net.URLConnection connection)
Creates a new multipart POST HTTP request on a freshly opened URLConnection |
Method Summary | |
---|---|
protected void |
connect()
Opens the output stream if it is not already open |
protected void |
newline()
Writes a newline character (\r\n) to the output stream, opening the output stream if required |
java.io.InputStream |
post()
posts the requests to the server, with all the cookies and parameters that were added |
java.io.InputStream |
post(java.util.Map 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 |
java.io.InputStream |
post(java.util.Map cookies,
java.util.Map 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 |
java.io.InputStream |
post(java.lang.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 |
java.io.InputStream |
post(java.lang.String[] cookies,
java.lang.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 |
java.io.InputStream |
post(java.lang.String name,
java.lang.Object value)
post the POST request to the server, with the specified parameter |
java.io.InputStream |
post(java.lang.String name1,
java.lang.Object value1,
java.lang.String name2,
java.lang.Object value2)
post the POST request to the server, with the specified parameters |
java.io.InputStream |
post(java.lang.String name1,
java.lang.Object value1,
java.lang.String name2,
java.lang.Object value2,
java.lang.String name3,
java.lang.Object value3)
post the POST request to the server, with the specified parameters |
java.io.InputStream |
post(java.lang.String name1,
java.lang.Object value1,
java.lang.String name2,
java.lang.Object value2,
java.lang.String name3,
java.lang.Object value3,
java.lang.String name4,
java.lang.Object value4)
post the POST request to the server, with the specified parameters |
static java.io.InputStream |
post(java.net.URL url,
java.util.Map parameters)
posts a new request to specified URL, with parameters that are passed in the argument |
static java.io.InputStream |
post(java.net.URL url,
java.util.Map cookies,
java.util.Map parameters)
posts a new request to specified URL, with cookies and parameters that are passed in the argument |
static java.io.InputStream |
post(java.net.URL url,
java.lang.Object[] parameters)
posts a new request to specified URL, with parameters that are passed in the argument |
static java.io.InputStream |
post(java.net.URL url,
java.lang.String[] cookies,
java.lang.Object[] parameters)
posts a new request to specified URL, with cookies and parameters that are passed in the argument |
static java.io.InputStream |
post(java.net.URL url,
java.lang.String name1,
java.lang.Object value1)
post the POST request specified URL, with the specified parameter |
static java.io.InputStream |
post(java.net.URL url,
java.lang.String name1,
java.lang.Object value1,
java.lang.String name2,
java.lang.Object value2)
post the POST request to specified URL, with the specified parameters |
static java.io.InputStream |
post(java.net.URL url,
java.lang.String name1,
java.lang.Object value1,
java.lang.String name2,
java.lang.Object value2,
java.lang.String name3,
java.lang.Object value3)
post the POST request to specified URL, with the specified parameters |
static java.io.InputStream |
post(java.net.URL url,
java.lang.String name1,
java.lang.Object value1,
java.lang.String name2,
java.lang.Object value2,
java.lang.String name3,
java.lang.Object value3,
java.lang.String name4,
java.lang.Object value4)
post the POST request to specified URL, with the specified parameters |
protected static java.lang.String |
randomString()
Generates a random string to use in the boundary |
void |
setCookie(java.lang.String name,
java.lang.String value)
adds a cookie to the requst |
void |
setCookies(java.util.Map cookies)
adds cookies to the request |
void |
setCookies(java.lang.String[] cookies)
adds cookies to the request |
void |
setParameter(java.lang.String name,
java.io.File file)
adds a file parameter to the request |
void |
setParameter(java.lang.String name,
java.lang.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(java.lang.String name,
java.lang.String value)
adds a string parameter to the request |
void |
setParameter(java.lang.String name,
java.lang.String filename,
java.io.InputStream is)
adds a file parameter to the request |
void |
setParameters(java.util.Map parameters)
adds parameters to the request |
void |
setParameters(java.lang.Object[] parameters)
adds parameters to the request |
protected void |
write(char c)
Writes a single character to the output stream, opening the output stream if required |
protected void |
write(java.lang.String s)
Writes a string to the output stream, opening the output stream if required |
protected void |
writeln(java.lang.String s)
Writes a String to the output stream, followed by a newline opening the output stream if required |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClientHttpRequest(java.net.URLConnection connection) throws java.io.IOException
connection
- an already open URL connection
java.io.IOException
- thrown if problem making connectionpublic ClientHttpRequest(java.net.URL url) throws java.io.IOException
url
- the URL to send request to
java.io.IOException
- thrown if problem making connectionpublic ClientHttpRequest(java.lang.String urlString) throws java.io.IOException
urlString
- the string representation of the URL to send request to
java.io.IOException
- thrown if problem making connectionMethod Detail |
---|
protected void connect() throws java.io.IOException
java.io.IOException
- throws an exception if connect failsprotected void write(char c) throws java.io.IOException
c
- the character to write
java.io.IOException
- throws an exception if connect or write failsprotected void write(java.lang.String s) throws java.io.IOException
s
- the String to write
java.io.IOException
- throws an exception if connect or write failsprotected void newline() throws java.io.IOException
java.io.IOException
- throws an exception if connect or write failsprotected void writeln(java.lang.String s) throws java.io.IOException
s
- the String to write
java.io.IOException
- throws an exception if connect or write failsprotected static java.lang.String randomString()
public void setCookie(java.lang.String name, java.lang.String value) throws java.io.IOException
name
- cookie namevalue
- cookie value
java.io.IOException
- thrown if problem with connectionpublic void setCookies(java.util.Map cookies) throws java.io.IOException
cookies
- the cookie "name-to-value" map
java.io.IOException
- thrown if problem with connectionpublic void setCookies(java.lang.String[] cookies) throws java.io.IOException
cookies
- array of cookie names and values (cookies[2*i] is a name, cookies[2*i + 1] is a value)
java.io.IOException
- thrown if problem with connectionpublic void setParameter(java.lang.String name, java.lang.String value) throws java.io.IOException
name
- parameter namevalue
- parameter value
java.io.IOException
- thrown if problem with connectionpublic void setParameter(java.lang.String name, java.lang.String filename, java.io.InputStream is) throws java.io.IOException
name
- parameter namefilename
- the name of the fileis
- input stream to read the contents of the file from
java.io.IOException
- thrown if problem with connectionpublic void setParameter(java.lang.String name, java.io.File file) throws java.io.IOException
name
- parameter namefile
- the file to upload
java.io.IOException
- thrown if problem with connectionpublic void setParameter(java.lang.String name, java.lang.Object object) throws java.io.IOException
name
- parameter nameobject
- parameter value, a File or anything else that can be stringified
java.io.IOException
- thrown if problem with connectionpublic void setParameters(java.util.Map parameters) throws java.io.IOException
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 request
java.io.IOException
- thrown if problem with connectionpublic void setParameters(java.lang.Object[] parameters) throws java.io.IOException
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 request
java.io.IOException
- thrown if problem with connectionpublic java.io.InputStream post() throws java.io.IOException
java.io.IOException
- thrown if problem with connectionpublic java.io.InputStream post(java.util.Map parameters) throws java.io.IOException
parameters
- request parameters
java.io.IOException
- thrown if problem with connectionpublic java.io.InputStream post(java.lang.Object[] parameters) throws java.io.IOException
parameters
- request parameters
java.io.IOException
- thrown if problem with connectionpublic java.io.InputStream post(java.util.Map cookies, java.util.Map parameters) throws java.io.IOException
cookies
- request cookiesparameters
- request parameters
java.io.IOException
- thrown if problem with connectionpublic java.io.InputStream post(java.lang.String[] cookies, java.lang.Object[] parameters) throws java.io.IOException
cookies
- request cookiesparameters
- request parameters
java.io.IOException
- thrown if problem with connectionpublic java.io.InputStream post(java.lang.String name, java.lang.Object value) throws java.io.IOException
name
- parameter namevalue
- parameter value
java.io.IOException
- thrown if problem with connectionpublic java.io.InputStream post(java.lang.String name1, java.lang.Object value1, java.lang.String name2, java.lang.Object value2) throws java.io.IOException
name1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter value
java.io.IOException
- thrown if problem with connectionpublic java.io.InputStream post(java.lang.String name1, java.lang.Object value1, java.lang.String name2, java.lang.Object value2, java.lang.String name3, java.lang.Object value3) throws java.io.IOException
name1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter valuename3
- third parameter namevalue3
- third parameter value
java.io.IOException
- thrown if problem with connectionpublic java.io.InputStream post(java.lang.String name1, java.lang.Object value1, java.lang.String name2, java.lang.Object value2, java.lang.String name3, java.lang.Object value3, java.lang.String name4, java.lang.Object value4) throws java.io.IOException
name1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter valuename3
- third parameter namevalue3
- third parameter valuename4
- fourth parameter namevalue4
- fourth parameter value
java.io.IOException
- thrown if problem with connectionpublic static java.io.InputStream post(java.net.URL url, java.util.Map parameters) throws java.io.IOException
url
- The URL to post toparameters
- request parameters
java.io.IOException
- thrown if problem with connectionpublic static java.io.InputStream post(java.net.URL url, java.lang.Object[] parameters) throws java.io.IOException
parameters
- request parametersurl
- The URL to post to
java.io.IOException
- thrown if problem with connectionpublic static java.io.InputStream post(java.net.URL url, java.util.Map cookies, java.util.Map parameters) throws java.io.IOException
url
- The URL to post tocookies
- request cookiesparameters
- request parameters
java.io.IOException
- thrown if problem with connectionpublic static java.io.InputStream post(java.net.URL url, java.lang.String[] cookies, java.lang.Object[] parameters) throws java.io.IOException
url
- The URL to post tocookies
- request cookiesparameters
- request parameters
java.io.IOException
- thrown if problem with connectionpublic static java.io.InputStream post(java.net.URL url, java.lang.String name1, java.lang.Object value1) throws java.io.IOException
url
- The URL to post toname1
- parameter namevalue1
- parameter value
java.io.IOException
- thrown if problem with connectionpublic static java.io.InputStream post(java.net.URL url, java.lang.String name1, java.lang.Object value1, java.lang.String name2, java.lang.Object value2) throws java.io.IOException
url
- The URL to post toname1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter value
java.io.IOException
- thrown if problem with connectionpublic static java.io.InputStream post(java.net.URL url, java.lang.String name1, java.lang.Object value1, java.lang.String name2, java.lang.Object value2, java.lang.String name3, java.lang.Object value3) throws java.io.IOException
url
- The URL to post toname1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter valuename3
- third parameter namevalue3
- third parameter value
java.io.IOException
- thrown if problem with connectionpublic static java.io.InputStream post(java.net.URL url, java.lang.String name1, java.lang.Object value1, java.lang.String name2, java.lang.Object value2, java.lang.String name3, java.lang.Object value3, java.lang.String name4, java.lang.Object value4) throws java.io.IOException
url
- The URL to post toname1
- first parameter namevalue1
- first parameter valuename2
- second parameter namevalue2
- second parameter valuename3
- third parameter namevalue3
- third parameter valuename4
- fourth parameter namevalue4
- fourth parameter value
java.io.IOException
- thrown if problem with connection
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |