|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCOM.FutureTense.Util.FormPoster
This class allows for the construction and posting of multipart mime encoded messages much as would be sent from a web browser posting the results of an HTML form
Field Summary | |
static java.lang.String |
Connect
CONNECT action |
static java.lang.String |
Delete
DELETE action |
static int |
ERRORBADRESPONSE
Error server response did not contain handshake code |
static int |
ERRORFILEIO
File I/O error |
static int |
ERRORGENERAL
General error |
static int |
ERRORILLEGALDATAFORACTION
File data used with Get Method error |
static int |
ERRORNETDISCONNECT
Error network disconnected |
static int |
ERRORNOCONSERVER
Error can't connect to server |
static int |
ERRORNOTAUTHENTICATED
Server certificate does not match what is expected |
static int |
ERRORNOURLPARAM
Error bad URL input params |
static int |
ERROROUTOFMEMORY
Error - out of memory reading a server response |
static int |
ERRORSUCCESS
Error success |
static int |
ERRORTIMEOUT
Error network timeout forced |
static java.lang.String |
Get
GET action |
static java.lang.String |
Head
HEAD action |
static java.lang.String |
HTTP_ACCEPT_CHARSET
|
static java.lang.String |
HTTP_ACCEPT_LANGUAGE
|
static java.lang.String |
HTTP_ACCEPT_MIME_TYPES
|
static java.lang.String |
HTTP_CONNECTION
|
static java.lang.String |
HTTP_CONTENT_LENGTH
|
static java.lang.String |
HTTP_CONTENT_TYPE
|
static java.lang.String |
HTTP_CONTENT_TYPE_CHARSET
|
static java.lang.String |
HTTP_EXPIRES
|
static java.lang.String |
HTTP_LAST_MODIFIED
|
static java.lang.String |
HTTP_POST_FORMMULTIPART
|
static java.lang.String |
HTTP_POST_FORMURLENCODED
|
static java.lang.String |
HTTP_REFERER
|
static java.lang.String |
HTTP_SET_COOKIE
|
static java.lang.String |
HTTP_USER_AGENT
|
static int |
HTTPRESPONSENOPAGEFOUND
|
static int |
HTTPRESPONSENOSERVICE
|
static int |
HTTPRESPONSENOTOK
HTTP Errors... |
static int |
HTTPRESPONSEOK
HTTP Success |
static int |
HTTPRESPONSETIMEOUT
|
static int |
HTTPVERSION10
HTTP 1.0 flag |
static int |
HTTPVERSION11
HTTP 1.1 flag |
static java.lang.String |
Options
PUT action |
static java.lang.String |
PATH_INFO
|
static java.lang.String |
Post
POST action |
static java.lang.String |
Put
PUT action |
static java.lang.String |
REMOTE_ADDR
|
static java.lang.String |
REMOTE_HOST
|
static java.lang.String |
Trace
TRACE action |
Constructor Summary | |
FormPoster()
Construct a new object for post |
Method Summary | |
boolean |
addFile(java.lang.String sParamName,
java.lang.String sValue,
java.lang.String sFileName)
Add a file (upload file path spec) to data for multipart post, as in INPUT TYPE=FILE |
boolean |
addFile(java.lang.String sParamName,
java.lang.String sValue,
java.lang.String sFileName,
java.lang.String sMIMEType)
Add a file (upload file path spec) to data for multipart post, as in INPUT TYPE=FILE Allow specifing of mime type string. |
boolean |
addFileData(java.lang.String sParamName,
java.lang.String sFileName,
byte[] byData)
Add file (upload) data via a byte array for multipart post, as in INPUT TYPE=FILE |
boolean |
addFileData(java.lang.String sParamName,
java.lang.String sFileName,
byte[] byData,
java.lang.String sMIMEType)
Add file (upload) data via a byte array for multipart post, as in INPUT TYPE=FILE |
boolean |
addFileData(java.lang.String sParamName,
java.lang.String sFileName,
java.io.InputStream is)
Add file (upload) data via a InputStream object for multipart post, as in INPUT TYPE=FILE |
boolean |
addFileData(java.lang.String sParamName,
java.lang.String sFileName,
java.io.InputStream is,
java.lang.String sMIMEType)
Add file (upload) data via a InputStream object for multipart post, as in INPUT TYPE=FILE |
boolean |
addTextValue(java.lang.String sParamName,
java.lang.String sValue)
Adds a name/value pair to the MIME message we're assembling. |
boolean |
addURL(java.lang.String sParamName,
java.lang.String sURL)
Add a url ("http://" or "https://") to data for multipart post, as in INPUT TYPE=FILE |
byte[] |
cleanRawResponse()
Fetch the raw bytes from the output stream and remove the HTTP header. |
byte[] |
cleanRawResponse(boolean bRemoveStatus)
Fetch the raw bytes from the output stream and remove the HTTP header. |
java.lang.String |
cleanResponse()
Fetch the string from the output stream and remove the HTTP header. |
java.lang.String |
cleanResponse(boolean bRemoveStatus)
Fetch the string from the output stream and remove the HTTP header. |
void |
dumpMsg(java.lang.String msg)
Send a String message to stdout or a log file
if one was selected via setLog. |
FTValList |
findAllCookies()
Find the cookies in the post response |
static FTValList |
findAllCookies(java.lang.String sData)
Find all cookie values in the HTTP response |
static COM.FutureTense.Util.CookieWrapper[] |
getCookieArray(java.lang.String sData)
Find all cookie values in the HTTP response |
FTValList |
getCookies()
Return FTValList containing all cookie names/values |
int |
getHTTPStatusCode()
Fetch the HTTP status from the response |
java.lang.String |
getHTTPStatusText()
Fetch the HTTP status text from the response |
int |
getLastError()
Retrieve the last error code set |
java.lang.String |
getLastErrorStr()
Retrieve any coded message from the status code object |
java.lang.String |
getLastErrorText()
Retrieve the text represenation of the error returned by getLastError() |
java.lang.String |
getOutputFileSpec()
Fetch the file spec where the post output has been written |
byte[] |
getRawResponse()
Fetch the raw bytes from the output stream |
java.lang.String |
getResponse()
Returns String response from the server after we
post() our request. |
java.lang.String |
getResponseEncoding()
Method to get the character encoding of the response if known |
javax.servlet.http.Cookie[] |
getServletCookies()
Get HTTPServlet cookies |
void |
login(boolean login,
COM.FutureTense.Util.ftStatusCode status,
java.lang.String user,
java.lang.String pass)
Login or logout Set the url first in the FormPoster otherwise it will attempt to default to a NAS 2.1 style URL |
boolean |
post()
Send this record via an HTTP POST. |
void |
registerMIMENotifier(COM.FutureTense.Interfaces.IMIMENotifier mn)
Register an object that supports the IMIMENotifier interface so that it will be called with MIME header information. |
void |
reset()
Reset to reuse for a new post |
void |
setAction(java.lang.String sAction)
Sets the action for this request. |
void |
setAutenticationParameters(java.lang.String sEntity,
java.lang.String sIssuer)
Set the certificate parameters to be used to authenticate the server. |
void |
setBodyData(byte[] data)
Pass a prebuilt MIME body for posting |
void |
setBodyStream(java.lang.Object is,
int length)
Pass a prebuilt MIME body for posting |
void |
setCharacterEncoding(java.lang.String sEncoding)
Set the character encoding for the string data contained in the MIME request message body Ignored when the transmission method is Get |
void |
setCookies(javax.servlet.http.Cookie[] c)
Use these cookies in the future |
void |
setCookies(java.util.Map cookiesMap)
Use these cookies in the future |
void |
setDump(boolean dumpOutput)
Control status logging info; default is false |
boolean |
setEncodeURL(java.lang.String sURL)
Set the URL to post to. |
void |
setHeaderInformation(FTValList vlHeaderInfo)
Use the header information supplied |
void |
setHTTPVersion(int nVersion)
Set the HTTP protocol version to use. |
void |
setLog(COM.FutureTense.Util.LogFile logFile)
Supply a logging object if desired for special log types; not required, output will stream to default location based on invocation environment |
void |
setLog(java.lang.String logdir)
Provide a standard ascii file dump location for logging in absense of LogFile object |
void |
setOutputDirectory(java.lang.String sDir)
Set the directory where the post results output file should be written. |
void |
setOutputStream(java.io.OutputStream os)
Set an output stream to be used for capturing the response. |
void |
setPort(int nPort)
Set the port to be used to connect to the remote http server |
void |
setProxy(java.lang.String sHost)
Set the proxy host if needed to post thru a fire wall |
void |
setProxyPort(int nPort)
Specify a proxy server port if needed to push data thru a firewall |
void |
setSecureProtocol(boolean bSecure)
Communicate in secure (https) mode. |
void |
setTimeout(int milliseconds)
Set a network socket connection timeout, in milliseconds. |
boolean |
setURL(java.lang.String sURL)
Set the URL to post to. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ERRORSUCCESS
public static final int ERRORNOCONSERVER
public static final int ERRORNETDISCONNECT
public static final int ERRORNOURLPARAM
public static final int ERRORTIMEOUT
public static final int ERRORBADRESPONSE
public static final int ERRORNOTAUTHENTICATED
public static final int ERROROUTOFMEMORY
public static final int ERRORGENERAL
public static final int ERRORFILEIO
public static final int ERRORILLEGALDATAFORACTION
public static final int HTTPVERSION10
public static final int HTTPVERSION11
public static final java.lang.String Post
public static final java.lang.String Get
public static final java.lang.String Connect
public static final java.lang.String Delete
public static final java.lang.String Head
public static final java.lang.String Options
public static final java.lang.String Put
public static final java.lang.String Trace
public static final int HTTPRESPONSEOK
public static final int HTTPRESPONSENOTOK
public static final int HTTPRESPONSENOPAGEFOUND
public static final int HTTPRESPONSETIMEOUT
public static final int HTTPRESPONSENOSERVICE
public static final java.lang.String HTTP_ACCEPT_LANGUAGE
public static final java.lang.String HTTP_REFERER
public static final java.lang.String REMOTE_HOST
public static final java.lang.String REMOTE_ADDR
public static final java.lang.String HTTP_CONNECTION
public static final java.lang.String PATH_INFO
public static final java.lang.String HTTP_USER_AGENT
public static final java.lang.String HTTP_ACCEPT_MIME_TYPES
public static final java.lang.String HTTP_ACCEPT_CHARSET
public static final java.lang.String HTTP_SET_COOKIE
public static final java.lang.String HTTP_CONTENT_TYPE_CHARSET
public static final java.lang.String HTTP_CONTENT_TYPE
public static final java.lang.String HTTP_CONTENT_LENGTH
public static final java.lang.String HTTP_EXPIRES
public static final java.lang.String HTTP_LAST_MODIFIED
public static final java.lang.String HTTP_POST_FORMMULTIPART
public static final java.lang.String HTTP_POST_FORMURLENCODED
Constructor Detail |
public FormPoster()
Method Detail |
public javax.servlet.http.Cookie[] getServletCookies()
public FTValList getCookies()
public void setCookies(javax.servlet.http.Cookie[] c)
c
- cookie array, null to clearpublic void setCookies(java.util.Map cookiesMap)
cookiesMap
- - Map containing cookie name/value pairspublic void setHeaderInformation(FTValList vlHeaderInfo)
vlHeaderInfo
- - vallist containing header informationpublic void setBodyData(byte[] data)
data
- public void setBodyStream(java.lang.Object is, int length)
is
- mime bodylength
- length of bodypublic void reset()
public void login(boolean login, COM.FutureTense.Util.ftStatusCode status, java.lang.String user, java.lang.String pass)
login
- - TRUE login otherwise logoutstatus
- - optional if specified return status will be setuser
- - username to use to log inpass
- - password to use to log inpublic void setDump(boolean dumpOutput)
dumpOutput
- whether to dump output msgspublic void setOutputDirectory(java.lang.String sDir)
sDir
- - directory path. If null, no output file writtenpublic void setOutputStream(java.io.OutputStream os)
os
- output stream (not closed)public void setCharacterEncoding(java.lang.String sEncoding)
sEncoding
- character encodingpublic java.lang.String getOutputFileSpec()
public java.lang.String getResponse()
String
response from the server after we
post() our request.
public byte[] getRawResponse()
public final java.lang.String getResponseEncoding()
public byte[] cleanRawResponse(boolean bRemoveStatus)
bRemoveStatus
- boolean flag
public byte[] cleanRawResponse()
public int getLastError()
public java.lang.String getLastErrorText()
public java.lang.String getLastErrorStr()
public int getHTTPStatusCode()
public java.lang.String getHTTPStatusText()
public void setLog(COM.FutureTense.Util.LogFile logFile)
logFile
- an object which
can construct a logging outputpublic void setLog(java.lang.String logdir)
logdir
- path to log directory
and 'wwwresponse.log' will be appended to
create a logfilepublic void setAction(java.lang.String sAction) throws java.lang.Exception
sAction
- action
java.lang.Exception
- if invalid actionpublic boolean addURL(java.lang.String sParamName, java.lang.String sURL)
sParamName
- - the parameter namesURL
- - URL to fetch
public boolean addFileData(java.lang.String sParamName, java.lang.String sFileName, byte[] byData)
sParamName
- - the parameter namesFileName
- - desired name of the file on the target (ie foo.txt)byData
- byte array containing file data
public boolean addFileData(java.lang.String sParamName, java.lang.String sFileName, byte[] byData, java.lang.String sMIMEType)
sParamName
- - the parameter namesFileName
- - desired name of the file on the target (ie foo.txt)byData
- byte array containing file datasMIMEType
- MIME type of the data
public boolean addFileData(java.lang.String sParamName, java.lang.String sFileName, java.io.InputStream is, java.lang.String sMIMEType)
sParamName
- - the parameter namesFileName
- - desired name of the file on the target (ie foo.txt)is
- - the object from where the file data will be readsMIMEType
- MIME type of the data
public boolean addFileData(java.lang.String sParamName, java.lang.String sFileName, java.io.InputStream is)
sParamName
- - the parameter namesFileName
- - desired name of the file on the target (ie foo.txt)is
- - the object from where the file data will be read
public boolean addFile(java.lang.String sParamName, java.lang.String sValue, java.lang.String sFileName)
sParamName
- - the parameter namesValue
- - value of the parameter (usually the file name)sFileName
- - name of the file to add
public boolean addFile(java.lang.String sParamName, java.lang.String sValue, java.lang.String sFileName, java.lang.String sMIMEType)
sParamName
- - the parameter namesValue
- - value of the parameter (usually the file name)sFileName
- - name of the file to addsMIMEType
- - MIME type string
public boolean addTextValue(java.lang.String sParamName, java.lang.String sValue)
sParamName
- - name of the parametersValue
- - value string of the parameter
public boolean setEncodeURL(java.lang.String sURL)
public boolean setURL(java.lang.String sURL)
public void setProxy(java.lang.String sHost)
sHost
- hostpublic void setProxyPort(int nPort)
nPort
- portpublic void setTimeout(int milliseconds)
milliseconds
- timeout in millisecondspublic void setSecureProtocol(boolean bSecure)
bSecure
- If set after URL is
set, will override the default which
was determined from the URL protocolpublic void setPort(int nPort)
nPort
- port. If set after URL is
set, will override the default which
was determined from the URL protocolpublic void setHTTPVersion(int nVersion) throws java.lang.Exception
nVersion
- protocol.
Input should be one of:
FormPoster.HTTPVERSION10 or
FormPoster.HTTPVERSION11
java.lang.Exception
- if invalid http versionpublic boolean post()
public void dumpMsg(java.lang.String msg)
String
message to stdout or a log file
if one was selected via setLog.
msg
- - the message to displaypublic FTValList findAllCookies()
public static COM.FutureTense.Util.CookieWrapper[] getCookieArray(java.lang.String sData)
sData
- data - HTTP response string
public static FTValList findAllCookies(java.lang.String sData)
sData
- data - HTTP response string
public java.lang.String cleanResponse(boolean bRemoveStatus)
bRemoveStatus
- - TRUE remove status, FALSE otherwise
public java.lang.String cleanResponse()
public void setAutenticationParameters(java.lang.String sEntity, java.lang.String sIssuer)
sEntity
- String expected name of the entitysIssuer
- String expected certificate issuer name (ie verisign)public void registerMIMENotifier(COM.FutureTense.Interfaces.IMIMENotifier mn)
mn
- IMIMENotifer object which supports IMIMENotifier
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |