public class HttpRequest
extends java.lang.Thread
Constructor and Description |
---|
HttpRequest(java.lang.String sUrl)
Create new request for the given URL
|
HttpRequest(java.lang.String sUrl,
java.net.URL oReferUrl,
java.lang.String sMethod,
NameValuePair[] aParams)
Create new request for the given URL
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
encoding()
Get response encoding
|
java.lang.Object |
get()
Perform HTTP GET request
|
java.util.ArrayList<NameValuePair> |
getCookies()
Get cookies readed from the last get or post call
|
java.lang.String |
getLanguage()
Get response HTML document content language
|
java.lang.String |
getTitle()
Get response HTML document title
|
int |
head()
Perform HTTP HEAD request
|
java.lang.Object |
post()
Perform HTTP POST request
|
int |
responseCode()
Get response code from last GET, POST or HEAD request
|
void |
run() |
void |
setCookies(java.util.ArrayList<NameValuePair> aCookies)
Set cookies foor next call to get or post method
|
java.lang.String |
src()
Get response as String
|
java.lang.String |
url() |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public HttpRequest(java.lang.String sUrl)
sUrl
- Stringpublic HttpRequest(java.lang.String sUrl, java.net.URL oReferUrl, java.lang.String sMethod, NameValuePair[] aParams)
sUrl
- String requested URLoReferUrl
- String Referer URLsMethod
- String Must be "get" or "post"aParams
- Array of NameValuePair with parameters to be sent along with get or postpublic java.util.ArrayList<NameValuePair> getCookies()
public void setCookies(java.util.ArrayList<NameValuePair> aCookies)
aCookies
- ArrayListpublic void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public java.lang.Object post() throws java.io.IOException, java.net.URISyntaxException, java.net.MalformedURLException
java.io.IOException
- if server returned any status different from HTTP_MOVED_PERM (301), HTTP_MOVED_TEMP (302), HTTP_OK (200) or HTTP_ACCEPTED (202)java.net.URISyntaxException
java.net.MalformedURLException
public java.lang.String url()
public java.lang.Object get() throws java.io.IOException, java.net.URISyntaxException, java.net.MalformedURLException
java.io.IOException
- if server returned any status different from HTTP_MOVED_PERM (301), HTTP_MOVED_TEMP (302), HTTP_OK (200) or HTTP_ACCEPTED (202)java.net.URISyntaxException
java.net.MalformedURLException
public int head() throws java.io.IOException, java.net.URISyntaxException, java.net.MalformedURLException
java.io.IOException
java.net.URISyntaxException
java.net.MalformedURLException
public int responseCode()
public java.lang.String src() throws java.io.IOException, java.io.UnsupportedEncodingException, java.net.URISyntaxException
java.io.IOException
java.io.UnsupportedEncodingException
java.net.URISyntaxException
public java.lang.String encoding() throws java.io.IOException, java.io.UnsupportedEncodingException, java.net.URISyntaxException
java.io.IOException
java.io.UnsupportedEncodingException
java.net.URISyntaxException
public java.lang.String getTitle() throws java.io.IOException, java.net.URISyntaxException, java.net.MalformedURLException, java.io.UnsupportedEncodingException
java.io.IOException
java.net.URISyntaxException
java.net.MalformedURLException
java.io.UnsupportedEncodingException
public java.lang.String getLanguage() throws java.io.IOException, java.net.URISyntaxException, java.net.MalformedURLException, java.io.UnsupportedEncodingException, org.htmlparser.util.ParserException
java.io.IOException
org.htmlparser.util.ParserException
java.net.URISyntaxException
java.net.MalformedURLException
java.io.UnsupportedEncodingException