|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jsoup.helper.HttpConnection
public class HttpConnection
Implementation of Connection.
Jsoup.connect(String)| Nested Class Summary | |
|---|---|
static class |
HttpConnection.KeyVal
|
static class |
HttpConnection.Request
|
static class |
HttpConnection.Response
|
| Nested classes/interfaces inherited from interface org.jsoup.Connection |
|---|
Connection.Method |
| Field Summary | |
|---|---|
static String |
CONTENT_ENCODING
|
| Method Summary | |
|---|---|
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 |
data(String key,
String filename,
InputStream inputStream)
Add an input stream as a request data paramater. |
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 |
postDataCharset(String charset)
Sets the default post data character set for x-www-form-urlencoded post data |
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. |
Connection |
validateTLSCertificates(boolean value)
Disable/enable TSL certificates validation for HTTPS requests. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String CONTENT_ENCODING
| Method Detail |
|---|
public static Connection connect(String url)
public static Connection connect(URL url)
public Connection url(URL url)
Connection
url in interface Connectionurl - URL to connect to
public Connection url(String url)
Connection
url in interface Connectionurl - URL to connect to
public Connection userAgent(String userAgent)
Connection
userAgent in interface ConnectionuserAgent - user-agent to use
public Connection timeout(int millis)
Connection
timeout in interface Connectionmillis - number of milliseconds (thousandths of a second) before timing out connects or reads.
public Connection maxBodySize(int bytes)
Connection
maxBodySize in interface Connectionbytes - number of bytes to read from the input before truncating
public Connection followRedirects(boolean followRedirects)
Connection
followRedirects in interface ConnectionfollowRedirects - true if server redirects should be followed.
public Connection referrer(String referrer)
Connection
referrer in interface Connectionreferrer - referrer to use
public Connection method(Connection.Method method)
Connection
method in interface Connectionmethod - HTTP request method
public Connection ignoreHttpErrors(boolean ignoreHttpErrors)
Connection
ignoreHttpErrors in interface ConnectionignoreHttpErrors - - false (default) if HTTP errors should be ignored.
public Connection ignoreContentType(boolean ignoreContentType)
Connection
ignoreContentType in interface ConnectionignoreContentType - set to true if you would like the content type ignored on parsing the response into a
Document.
public Connection validateTLSCertificates(boolean value)
ConnectionBy default this is true; all connections over HTTPS perform normal validation of certificates, and will abort requests if the provided certificate does not validate.
Some servers use expired, self-generated certificates; or your JDK may not support SNI hosts. In which case, you may want to enable this setting.
Be careful and understand why you need to disable these validations.
validateTLSCertificates in interface Connectionvalue - if should validate TSL (SSL) certificates. true by default.
public Connection data(String key,
String value)
Connection
data in interface Connectionkey - data keyvalue - data value
public Connection data(String key,
String filename,
InputStream inputStream)
Connection
data in interface Connectionkey - data key (form item name)filename - the name of the file to present to the remove server. Typically just the name, not path,
component.inputStream - the input stream to upload, that you probably obtained from a FileInputStream.
You must close the InputStream in a finally block.
public Connection data(Map<String,String> data)
Connection
data in interface Connectiondata - map of data parameters
public Connection data(String... keyvals)
Connection.data("name",
"jsoup", "language", "Java", "language", "English"); creates a query string like:
?name=jsoup&language=Java&language=English
data in interface Connectionkeyvals - a set of key value pairs.
public Connection data(Collection<Connection.KeyVal> data)
Connection
data in interface Connectiondata - collection of data parameters
public Connection header(String name,
String value)
Connection
header in interface Connectionname - header namevalue - header value
Connection.Base.headers()
public Connection cookie(String name,
String value)
Connection
cookie in interface Connectionname - name of cookievalue - value of cookie
public Connection cookies(Map<String,String> cookies)
Connection
cookies in interface Connectioncookies - map of cookie name -> value pairs
public Connection parser(Parser parser)
Connection
parser in interface Connectionparser - alternate parser
public Document get()
throws IOException
Connection
get in interface ConnectionMalformedURLException - if the request URL is not a HTTP or HTTPS URL, or is otherwise malformed
HttpStatusException - if the response is not OK and HTTP response errors are not ignored
UnsupportedMimeTypeException - if the response mime type is not supported and those errors are not ignored
SocketTimeoutException - if the connection times out
IOException - on error
public Document post()
throws IOException
Connection
post in interface ConnectionMalformedURLException - if the request URL is not a HTTP or HTTPS URL, or is otherwise malformed
HttpStatusException - if the response is not OK and HTTP response errors are not ignored
UnsupportedMimeTypeException - if the response mime type is not supported and those errors are not ignored
SocketTimeoutException - if the connection times out
IOException - on error
public Connection.Response execute()
throws IOException
Connection
execute in interface ConnectionMalformedURLException - if the request URL is not a HTTP or HTTPS URL, or is otherwise malformed
HttpStatusException - if the response is not OK and HTTP response errors are not ignored
UnsupportedMimeTypeException - if the response mime type is not supported and those errors are not ignored
SocketTimeoutException - if the connection times out
IOException - on errorpublic Connection.Request request()
Connection
request in interface Connectionpublic Connection request(Connection.Request request)
Connection
request in interface Connectionrequest - new request object
public Connection.Response response()
Connection
response in interface Connectionpublic Connection response(Connection.Response response)
Connection
response in interface Connectionresponse - new response
public Connection postDataCharset(String charset)
Connection
postDataCharset in interface Connectioncharset - character set to encode post data
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||