public final class Post extends Http
DEBUGGING, DEFAULT_LENGTH, DEFAULT_RESPONSE_CODE, DEFAULT_RESPONSE_MESSAGE, EMBEDDED_COPYRIGHT, readTimeout, responseCode, responseMessage, url, UTF8Charset, VERSION_STRING
Constructor and Description |
---|
Post()
Constructor
|
Modifier and Type | Method and Description |
---|---|
(package private) java.lang.String |
getEncodedPostParms(java.nio.charset.Charset encoding)
get the parms for the command encoded, separated with & =.
|
java.lang.String |
send(java.lang.String host,
int port,
java.lang.String action,
java.nio.charset.Charset encoding)
Send a form full of data to the CGI host using POST
setPostParms must have been called previously, and possibly setParms as well.
|
java.lang.String |
send(java.net.URL url,
java.nio.charset.Charset encoding)
Send a form full of data to the CGI host using POST
Must have done a setParms(optional) and setPostParms beforehand.
|
void |
setContentType(java.lang.String contentType)
declare Mime Type of the message contents.
|
void |
setPostBody(java.lang.String body)
set the body of the post, after the post parms.
|
void |
setPostParms(java.lang.String... postParms)
set the parms that will be send in the Post body.
|
dumpHeaders, getEncodedParms, getRawResponseMessage, getReferer, getResponseCode, getResponseMessage, getURL, guessCharSet, processResponse, setConnectTimeout, setInstanceFollowRedirects, setParms, setReadTimeout, setReferer, setRequestProperties, setStandardProperties, setUserAgent
public java.lang.String send(java.net.URL url, java.nio.charset.Charset encoding)
url
- URL of the website, including host, path but not the parms.
Call setPostParms and setPostBody before calling send.
http: or https:encoding
- encoding of the byte stream result, usually UTF-8 or or ISO-8859-1.public java.lang.String send(java.lang.String host, int port, java.lang.String action, java.nio.charset.Charset encoding)
host
- domain of the website. no lead http:port
- -1 if default, 8081 for local echoserver.action
- action of form, page on website. Usually has a lead /.encoding
- encoding of the byte stream result, usually UTF-8 or or ISO-8859-1.public void setContentType(java.lang.String contentType)
contentType
- mime type of messagepublic void setPostBody(java.lang.String body)
body
- text to form the body of the post.setPostParms(String...)
public void setPostParms(java.lang.String... postParms)
postParms
- 0..n strings to be send as parameter, alternating keyword/value, not encoded.Http.setParms(String...)
java.lang.String getEncodedPostParms(java.nio.charset.Charset encoding) throws java.io.UnsupportedEncodingException
encoding
- encoding for URLEncoderjava.io.UnsupportedEncodingException
- if bad encoding