public class FormPoster extends Object
Modifier and Type | Field and Description |
---|---|
static String |
Connect
Deprecated.
CONNECT action
|
static String |
Delete
Deprecated.
DELETE action
|
static int |
ERRORBADRESPONSE
Deprecated.
Error server response did not contain handshake code
|
static int |
ERRORFILEIO
Deprecated.
File I/O error
|
static int |
ERRORGENERAL
Deprecated.
General error
|
static int |
ERRORILLEGALDATAFORACTION
Deprecated.
File data used with Get Method error
|
static int |
ERRORNETDISCONNECT
Deprecated.
Error network disconnected
|
static int |
ERRORNOCONSERVER
Deprecated.
Error can't connect to server
|
static int |
ERRORNOTAUTHENTICATED
Deprecated.
Server certificate does not match what is expected
|
static int |
ERRORNOURLPARAM
Deprecated.
Error bad URL input params
|
static int |
ERROROUTOFMEMORY
Deprecated.
Error - out of memory reading a server response
|
static int |
ERRORSUCCESS
Deprecated.
Error success
|
static int |
ERRORTIMEOUT
Deprecated.
Error network timeout forced
|
static String |
Get
Deprecated.
GET action
|
static String |
Head
Deprecated.
HEAD action
|
static String |
HTTP_ACCEPT_CHARSET
Deprecated.
|
static String |
HTTP_ACCEPT_LANGUAGE
Deprecated.
|
static String |
HTTP_ACCEPT_MIME_TYPES
Deprecated.
|
static String |
HTTP_CONNECTION
Deprecated.
|
static String |
HTTP_CONTENT_LENGTH
Deprecated.
|
static String |
HTTP_CONTENT_TYPE
Deprecated.
|
static String |
HTTP_CONTENT_TYPE_CHARSET
Deprecated.
|
static String |
HTTP_EXPIRES
Deprecated.
|
static String |
HTTP_LAST_MODIFIED
Deprecated.
|
static String |
HTTP_POST_FORMMULTIPART
Deprecated.
|
static String |
HTTP_POST_FORMURLENCODED
Deprecated.
|
static String |
HTTP_REFERER
Deprecated.
|
static String |
HTTP_SET_COOKIE
Deprecated.
|
static String |
HTTP_USER_AGENT
Deprecated.
|
static int |
HTTPRESPONSENOPAGEFOUND
Deprecated.
|
static int |
HTTPRESPONSENOSERVICE
Deprecated.
|
static int |
HTTPRESPONSENOTOK
Deprecated.
HTTP Errors...
|
static int |
HTTPRESPONSEOK
Deprecated.
HTTP Success
|
static int |
HTTPRESPONSETIMEOUT
Deprecated.
|
static int |
HTTPVERSION10
Deprecated.
HTTP 1.0 flag
|
static int |
HTTPVERSION11
Deprecated.
HTTP 1.1 flag
|
protected boolean |
m_bFileDataAdded
Deprecated.
|
protected byte[] |
m_byUserBodyData
Deprecated.
|
protected Object |
m_byUserBodyStream
Deprecated.
|
protected int |
m_byUserContentLength
Deprecated.
|
protected COM.FutureTense.Util.CookieWrapper[] |
m_Cookies
Deprecated.
|
protected int |
m_nLastError
Deprecated.
|
protected StringBuffer |
m_sbUserTextParams
Deprecated.
|
protected FTValList |
m_vlHeaderInfo
Deprecated.
|
static String |
Options
Deprecated.
PUT action
|
static String |
PATH_INFO
Deprecated.
|
static String |
Post
Deprecated.
POST action
|
static String |
Put
Deprecated.
PUT action
|
static String |
REMOTE_ADDR
Deprecated.
|
static String |
REMOTE_HOST
Deprecated.
|
static String |
Trace
Deprecated.
TRACE action
|
static String |
X_CSRF_TOKEN
Deprecated.
|
Constructor and Description |
---|
FormPoster()
Deprecated.
Construct a new object for post
|
FormPoster(boolean panicOnProblem)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
addCookieToVector(Vector vCookies, String sName, String sValue)
Deprecated.
|
boolean |
addFile(String sParamName, String sValue, String sFileName)
Deprecated.
Add a file (upload file path spec) to data for multipart post, as in INPUT TYPE=FILE
|
boolean |
addFile(String sParamName, String sValue, String sFileName, String sMIMEType)
Deprecated.
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(String sParamName, String sFileName, byte[] byData)
Deprecated.
Add file (upload) data via a byte array for multipart post, as in INPUT TYPE=FILE
|
boolean |
addFileData(String sParamName, String sFileName, byte[] byData, String sMIMEType)
Deprecated.
Add file (upload) data via a byte array for multipart post, as in INPUT TYPE=FILE
|
boolean |
addFileData(String sParamName, String sFileName, InputStream is)
Deprecated.
Add file (upload) data via a InputStream object for multipart post, as in INPUT TYPE=FILE
|
boolean |
addFileData(String sParamName, String sFileName, InputStream is, String sMIMEType)
Deprecated.
Add file (upload) data via a InputStream object for multipart post, as in INPUT TYPE=FILE
|
boolean |
addTextValue(String sParamName, String sValue)
Deprecated.
Adds a name/value pair to the MIME message we're assembling.
|
boolean |
addURL(String sParamName, String sURL)
Deprecated.
Add a url ("http://" or "https://") to data for multipart post, as in INPUT TYPE=FILE
|
protected void |
buildCookieArray()
Deprecated.
|
byte[] |
cleanRawResponse()
Deprecated.
Fetch the raw bytes from the output stream and remove the HTTP header.
|
byte[] |
cleanRawResponse(boolean bRemoveStatus)
Deprecated.
Fetch the raw bytes from the output stream and remove the HTTP header.
|
String |
cleanResponse()
Deprecated.
Fetch the string from the output stream and remove the HTTP header.
|
String |
cleanResponse(boolean bRemoveStatus)
Deprecated.
Fetch the string from the output stream and remove the HTTP header.
|
protected boolean |
doAuthentication()
Deprecated.
|
void |
dumpMsg(String msg)
Deprecated.
Send a String message to stdout or a log file if one was selected via setLog.
|
FTValList |
findAllCookies()
Deprecated.
Find the cookies in the post response
|
static FTValList |
findAllCookies(String sData)
Deprecated.
Find all cookie values in the HTTP response
|
static COM.FutureTense.Util.CookieWrapper[] |
getCookieArray(String sData)
Deprecated.
Find all cookie values in the HTTP response
|
FTValList |
getCookies()
Deprecated.
Return FTValList containing all cookie names/values
|
int |
getHTTPStatusCode()
Deprecated.
Fetch the HTTP status from the response
|
String |
getHTTPStatusText()
Deprecated.
Fetch the HTTP status text from the response
|
int |
getLastError()
Deprecated.
Retrieve the last error code set
|
String |
getLastErrorStr()
Deprecated.
Retrieve any coded message from the status code object
|
String |
getLastErrorText()
Deprecated.
Retrieve the text represenation of the error returned by getLastError()
|
String |
getOutputFileSpec()
Deprecated.
Fetch the file spec where the post output has been written
|
byte[] |
getRawResponse()
Deprecated.
Fetch the raw bytes from the output stream
|
String |
getResponse()
Deprecated.
Returns
String response from the server after we post() our request. |
String |
getResponseEncoding()
Deprecated.
Method to get the character encoding of the response if known
|
javax.servlet.http.Cookie[] |
getServletCookies()
Deprecated.
Get HTTPServlet cookies
|
protected String |
getStatusRecordToken(int nCount)
Deprecated.
|
String |
getX_CSRF_TOKEN_VALUE()
Deprecated.
|
protected void |
init()
Deprecated.
|
void |
login(boolean login, COM.FutureTense.Util.ftStatusCode status, String user, String pass)
Deprecated.
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()
Deprecated.
Send this record via an HTTP POST.
|
protected FTValList |
postProcessMIMEHeader(String sHeader)
Deprecated.
Called to post-process a mime header once the postconnector reads it
|
protected static void |
processCookie(int nIndex, String sData, Vector vCookies)
Deprecated.
|
protected byte[] |
readStream(InputStream is)
Deprecated.
|
void |
registerMIMENotifier(COM.FutureTense.Interfaces.IMIMENotifier mn)
Deprecated.
Register an object that supports the IMIMENotifier interface so that it will be called with MIME header information.
|
void |
reset()
Deprecated.
Reset to reuse for a new post
|
protected static String |
sanitizeString(String sIn)
Deprecated.
Clean a string by only returning a printable substring
|
void |
setAction(String sAction)
Deprecated.
Sets the action for this request.
|
void |
setAutenticationParameters(String sEntity, String sIssuer)
Deprecated.
Set the certificate parameters to be used to authenticate the server.
|
void |
setBodyData(byte[] data)
Deprecated.
Pass a prebuilt MIME body for posting
|
void |
setBodyStream(Object is, int length)
Deprecated.
Pass a prebuilt MIME body for posting
|
void |
setCharacterEncoding(String sEncoding)
Deprecated.
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)
Deprecated.
Use these cookies in the future
|
void |
setCookies(Map cookiesMap)
Deprecated.
Use these cookies in the future
|
void |
setDump(boolean dumpOutput)
Deprecated.
Control status logging info; default is false
|
boolean |
setEncodeURL(String sURL)
Deprecated.
Set the URL to post to.
|
void |
setHeaderInformation(FTValList vlHeaderInfo)
Deprecated.
Use the header information supplied
|
void |
setHTTPVersion(int nVersion)
Deprecated.
Set the HTTP protocol version to use.
|
void |
setLog(COM.FutureTense.Util.LogFile logFile)
Deprecated.
Supply a logging object if desired for special log types; not required, output will stream to default location based on invocation environment
|
void |
setLog(String logdir)
Deprecated.
Provide a standard ascii file dump location for logging in absense of LogFile object
|
void |
setOutputDirectory(String sDir)
Deprecated.
Set the directory where the post results output file should be written.
|
void |
setOutputStream(OutputStream os)
Deprecated.
Set an output stream to be used for capturing the response.
|
void |
setPort(int nPort)
Deprecated.
Set the port to be used to connect to the remote http server
|
void |
setProxy(String sHost)
Deprecated.
Set the proxy host if needed to post thru a fire wall
|
void |
setProxyPassword(String p)
Deprecated.
Specify a proxy server password if needed to push data thru a firewall
|
void |
setProxyPort(int nPort)
Deprecated.
Specify a proxy server port if needed to push data thru a firewall
|
void |
setProxyUser(String u)
Deprecated.
Specify a proxy server user if needed to push data thru a firewall
|
void |
setSecureProtocol(boolean bSecure)
Deprecated.
Communicate in secure (https) mode.
|
void |
setTimeout(int milliseconds)
Deprecated.
Set a network socket connection timeout, in milliseconds.
|
boolean |
setURL(String sURL)
Deprecated.
Set the URL to post to.
|
void |
setX_CSRF_TOKEN_VALUE(String xCSRFTOKENVALUE)
Deprecated.
|
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 String Post
public static final String Get
public static final String Connect
public static final String Delete
public static final String Head
public static final String Options
public static final String Put
public static final 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 String HTTP_ACCEPT_LANGUAGE
public static final String HTTP_REFERER
public static final String REMOTE_HOST
public static final String REMOTE_ADDR
public static final String HTTP_CONNECTION
public static final String PATH_INFO
public static final String HTTP_USER_AGENT
public static final String HTTP_ACCEPT_MIME_TYPES
public static final String HTTP_ACCEPT_CHARSET
public static final String X_CSRF_TOKEN
public static final String HTTP_SET_COOKIE
public static final String HTTP_CONTENT_TYPE_CHARSET
public static final String HTTP_CONTENT_TYPE
public static final String HTTP_CONTENT_LENGTH
public static final String HTTP_EXPIRES
public static final String HTTP_LAST_MODIFIED
public static final String HTTP_POST_FORMMULTIPART
public static final String HTTP_POST_FORMURLENCODED
protected int m_nLastError
protected byte[] m_byUserBodyData
protected Object m_byUserBodyStream
protected int m_byUserContentLength
protected COM.FutureTense.Util.CookieWrapper[] m_Cookies
protected FTValList m_vlHeaderInfo
protected StringBuffer m_sbUserTextParams
protected boolean m_bFileDataAdded
public FormPoster()
public FormPoster(boolean panicOnProblem)
protected void init()
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(Map cookiesMap)
cookiesMap
- - Map containing cookie name/value pairspublic void setHeaderInformation(FTValList vlHeaderInfo)
vlHeaderInfo
- - vallist containing header informationpublic void setBodyData(byte[] data)
data
- a datapublic void setBodyStream(Object is, int length)
is
- mime bodylength
- length of bodypublic void reset()
public void login(boolean login, COM.FutureTense.Util.ftStatusCode status, String user, 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(String sDir)
sDir
- - directory path. If null, no output file writtenpublic void setOutputStream(OutputStream os)
os
- output stream (not closed)public void setCharacterEncoding(String sEncoding)
sEncoding
- character encodingpublic String getOutputFileSpec()
public String getResponse()
String
response from the server after we post() our request.public byte[] getRawResponse()
public final String getResponseEncoding()
public byte[] cleanRawResponse(boolean bRemoveStatus)
bRemoveStatus
- boolean flagpublic byte[] cleanRawResponse()
public int getLastError()
public String getLastErrorText()
public String getLastErrorStr()
protected String getStatusRecordToken(int nCount)
public int getHTTPStatusCode()
public String getHTTPStatusText()
public void setLog(COM.FutureTense.Util.LogFile logFile)
logFile
- an object which can construct a logging outputpublic void setLog(String logdir)
logdir
- path to log directory and 'wwwresponse.log' will be appended to create a logfilepublic void setAction(String sAction) throws Exception
sAction
- actionException
- if invalid actionprotected byte[] readStream(InputStream is) throws IOException
IOException
public boolean addURL(String sParamName, String sURL)
sParamName
- - the parameter namesURL
- - URL to fetchpublic boolean addFileData(String sParamName, String sFileName, byte[] byData)
sParamName
- - the parameter namesFileName
- - desired name of the file on the target (ie foo.txt)byData
- byte array containing file datapublic boolean addFileData(String sParamName, String sFileName, byte[] byData, 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 datapublic boolean addFileData(String sParamName, String sFileName, InputStream is, 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 datapublic boolean addFileData(String sParamName, String sFileName, 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 readpublic boolean addFile(String sParamName, String sValue, String sFileName)
sParamName
- - the parameter namesValue
- - value of the parameter (usually the file name)sFileName
- - name of the file to addpublic boolean addFile(String sParamName, String sValue, String sFileName, String sMIMEType)
sParamName
- - the parameter namesValue
- - value of the parameter (usually the file name)sFileName
- - name of the file to addsMIMEType
- - MIME type stringpublic boolean addTextValue(String sParamName, String sValue)
sParamName
- - name of the parametersValue
- - value string of the parameterpublic boolean setEncodeURL(String sURL)
sURL
- a URLpublic boolean setURL(String sURL)
sURL
- a URLpublic void setProxy(String sHost)
sHost
- hostpublic void setProxyPort(int nPort)
nPort
- portpublic void setProxyUser(String u)
u
- usernamepublic void setProxyPassword(String p)
p
- passwordpublic 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 Exception
nVersion
- protocol. Input should be one of: FormPoster.HTTPVERSION10 or FormPoster.HTTPVERSION11Exception
- if invalid http versionpublic boolean post()
protected boolean doAuthentication()
public void dumpMsg(String msg)
msg
- - the message to displayprotected static String sanitizeString(String sIn)
sIn
- - the string to be cleanedprotected static void addCookieToVector(Vector vCookies, String sName, String sValue)
protected static void processCookie(int nIndex, String sData, Vector vCookies)
protected void buildCookieArray()
public FTValList findAllCookies()
public static COM.FutureTense.Util.CookieWrapper[] getCookieArray(String sData)
sData
- data - HTTP response stringpublic static FTValList findAllCookies(String sData)
sData
- data - HTTP response stringpublic String cleanResponse(boolean bRemoveStatus)
bRemoveStatus
- - TRUE remove status, FALSE otherwisepublic String cleanResponse()
public void setAutenticationParameters(String sEntity, String sIssuer)
sEntity
- String expected name of the entitysIssuer
- String expected certificate issuer name (ie verisign)protected FTValList postProcessMIMEHeader(String sHeader)
sHeader
- String MIME headerpublic void registerMIMENotifier(COM.FutureTense.Interfaces.IMIMENotifier mn)
mn
- IMIMENotifer object which supports IMIMENotifierpublic String getX_CSRF_TOKEN_VALUE()
public void setX_CSRF_TOKEN_VALUE(String xCSRFTOKENVALUE)