public class HttpConnection extends Object implements Connection
Connection.Zsoup.connect(String)| Modifier and Type | Class and Description |
|---|---|
static class |
HttpConnection.KeyVal |
static class |
HttpConnection.Request |
static class |
HttpConnection.Response |
Connection.Method| Modifier and Type | Method and Description |
|---|---|
static Connection |
connect(String url) |
static Connection |
connect(URL url) |
Connection |
cookie(String name,
String value)
Set a cookie to be sent in the request.
|
Connection |
cookies(Map<String,String> cookies)
Adds each of the supplied cookies to the request.
|
Connection |
data(Collection<Connection.KeyVal> data)
Adds all of the supplied data to the request data parameters
|
Connection |
data(Map<String,String> data)
Adds all of the supplied data to the request data parameters
|
Connection |
data(String... keyvals)
Add a number of request data parameters.
|
Connection |
data(String key,
String value)
Add a request data parameter.
|
Connection.Response |
execute()
Execute the request.
|
Connection |
followRedirects(boolean followRedirects)
Configures the connection to (not) follow server redirects.
|
Document |
get()
Execute the request as a GET, and parse the result.
|
Connection |
header(String name,
String value)
Set a request header.
|
Connection |
ignoreContentType(boolean ignoreContentType)
Ignore the document's Content-Type when parsing the response.
|
Connection |
ignoreHttpErrors(boolean ignoreHttpErrors)
Configures the connection to not throw exceptions when a HTTP error occurs.
|
Connection |
maxBodySize(int bytes)
Set the maximum bytes to read from the (uncompressed) connection into the body, before the connection is closed,
and the input truncated.
|
Connection |
method(Connection.Method method)
Set the request method to use, GET or POST.
|
Connection |
parser(Parser parser)
Provide an alternate parser to use when parsing the response to a Document.
|
Document |
post()
Execute the request as a POST, and parse the result.
|
Connection |
referrer(String referrer)
Set the request referrer (aka "referer") header.
|
Connection.Request |
request()
Get the request object associated with this connection
|
Connection |
request(Connection.Request request)
Set the connection's request
|
Connection.Response |
response()
Get the response, once the request has been executed
|
Connection |
response(Connection.Response response)
Set the connection's response
|
Connection |
timeout(int millis)
Set the request timeouts (connect and read).
|
Connection |
url(String url)
Set the request URL to fetch.
|
Connection |
url(URL url)
Set the request URL to fetch.
|
Connection |
userAgent(String userAgent)
Set the request user-agent header.
|
public static Connection connect(String url)
public static Connection connect(URL url)
public Connection url(URL url)
Connectionurl in interface Connectionurl - URL to connect topublic Connection url(String url)
Connectionurl in interface Connectionurl - URL to connect topublic Connection userAgent(String userAgent)
ConnectionuserAgent in interface ConnectionuserAgent - user-agent to usepublic Connection timeout(int millis)
Connectiontimeout in interface Connectionmillis - number of milliseconds (thousandths of a second) before timing out connects or reads.public Connection maxBodySize(int bytes)
ConnectionmaxBodySize in interface Connectionbytes - number of bytes to read from the input before truncatingpublic Connection followRedirects(boolean followRedirects)
ConnectionfollowRedirects in interface ConnectionfollowRedirects - true if server redirects should be followed.public Connection referrer(String referrer)
Connectionreferrer in interface Connectionreferrer - referrer to usepublic Connection method(Connection.Method method)
Connectionmethod in interface Connectionmethod - HTTP request methodpublic Connection ignoreHttpErrors(boolean ignoreHttpErrors)
ConnectionignoreHttpErrors in interface ConnectionignoreHttpErrors - - false (default) if HTTP errors should be ignored.public Connection ignoreContentType(boolean ignoreContentType)
ConnectionignoreContentType in interface ConnectionignoreContentType - set to true if you would like the content type ignored on parsing the response into a
Document.public Connection data(String key, String value)
Connectiondata in interface Connectionkey - data keyvalue - data valuepublic Connection data(Map<String,String> data)
Connectiondata in interface Connectiondata - map of data parameterspublic Connection data(String... keyvals)
Connection.data("name", "jsoup", "language", "Java", "language", "English"); creates a query string like:
?name=jsoup&language=Java&language=Englishdata in interface Connectionkeyvals - a set of key value pairs.public Connection data(Collection<Connection.KeyVal> data)
Connectiondata in interface Connectiondata - collection of data parameterspublic Connection header(String name, String value)
Connectionheader in interface Connectionname - header namevalue - header valueConnection.Base.headers()public Connection cookie(String name, String value)
Connectioncookie in interface Connectionname - name of cookievalue - value of cookiepublic Connection cookies(Map<String,String> cookies)
Connectioncookies in interface Connectioncookies - map of cookie name -> value pairspublic Connection parser(Parser parser)
Connectionparser in interface Connectionparser - alternate parserpublic Document get() throws IOException
Connectionget in interface ConnectionMalformedURLException - if the request URL is not a HTTP or HTTPS URL, or is otherwise malformedHttpStatusException - if the response is not OK and HTTP response errors are not ignoredUnsupportedMimeTypeException - if the response mime type is not supported and those errors are not ignoredSocketTimeoutException - if the connection times outIOException - on errorpublic Document post() throws IOException
Connectionpost in interface ConnectionMalformedURLException - if the request URL is not a HTTP or HTTPS URL, or is otherwise malformedHttpStatusException - if the response is not OK and HTTP response errors are not ignoredUnsupportedMimeTypeException - if the response mime type is not supported and those errors are not ignoredSocketTimeoutException - if the connection times outIOException - on errorpublic Connection.Response execute() throws IOException
Connectionexecute in interface ConnectionMalformedURLException - if the request URL is not a HTTP or HTTPS URL, or is otherwise malformedHttpStatusException - if the response is not OK and HTTP response errors are not ignoredUnsupportedMimeTypeException - if the response mime type is not supported and those errors are not ignoredSocketTimeoutException - if the connection times outIOException - on errorpublic Connection.Request request()
Connectionrequest in interface Connectionpublic Connection request(Connection.Request request)
Connectionrequest in interface Connectionrequest - new request objectpublic Connection.Response response()
Connectionresponse in interface Connectionpublic Connection response(Connection.Response response)
Connectionresponse in interface Connectionresponse - new responseCopyright © 2009-2015 Potix. All Rights Reserved.