public class HTTPRequest
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
java.net.URL |
url |
Constructor and Description |
---|
HTTPRequest(java.net.URL url)
Creates a new HTTPRequest object
|
Modifier and Type | Method and Description |
---|---|
java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> |
getLastConnectionHeaders()
Used to get the headers the webserver sent on our last connection
|
java.lang.String[] |
read()
Reads the entire page and returns a string array
|
java.lang.String[] |
read(int linesToRead)
Reads as many lines as expected unless it reaches the end.
|
java.lang.String |
readSingle()
Only reads the first line
|
java.lang.String |
readSingle(int linesToRead)
Reads until it reaches the expected line then it returns it.
|
void |
setCookie(java.lang.String cookie)
Set a cookie string to send to the web server
|
void |
setFollowRedirects(boolean setFollowRedirects)
By default follow redirects are enabled
|
void |
setPostData(java.lang.String postData)
Sets post data to send to the web server
|
void |
setProxy(java.net.Proxy proxy)
Sets a proxy to connect through
|
void |
setReferer(java.lang.String referer)
Sets a referer to send to the web server
|
void |
setTimeout(int timeout)
Sets the seconds till timeout, default 30,000 milliseconds
|
void |
setUseragent(java.lang.String useragent)
Sets a custom useragent, default 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0'
|
public HTTPRequest(java.net.URL url)
url
- public void setReferer(java.lang.String referer)
public void setCookie(java.lang.String cookie)
public void setPostData(java.lang.String postData)
public void setUseragent(java.lang.String useragent)
public void setTimeout(int timeout)
public void setProxy(java.net.Proxy proxy)
public java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> getLastConnectionHeaders()
public void setFollowRedirects(boolean setFollowRedirects)
public java.lang.String[] read() throws java.lang.Exception
java.lang.Exception
public java.lang.String[] read(int linesToRead) throws java.lang.Exception
linesToRead
- java.lang.Exception
public java.lang.String readSingle() throws java.lang.Exception
java.lang.Exception
public java.lang.String readSingle(int linesToRead) throws java.lang.Exception
linesToRead
- java.lang.Exception