Package org.jsoup
Interface Connection.Request
-
- All Superinterfaces:
Connection.Base<Connection.Request>
- All Known Implementing Classes:
HttpConnection.Request
- Enclosing interface:
- Connection
public static interface Connection.Request extends Connection.Base<Connection.Request>
Represents a HTTP request.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Collection<Connection.KeyVal>data()Get all of the request's data parametersConnection.Requestdata(Connection.KeyVal keyval)Add a data parameter to the requestbooleanfollowRedirects()Get the current followRedirects configuration.Connection.RequestfollowRedirects(boolean followRedirects)Configures the request to (not) follow server redirects.booleanignoreContentType()Get the current ignoreContentType configuration.Connection.RequestignoreContentType(boolean ignoreContentType)Configures the request to ignore the Content-Type of the response.booleanignoreHttpErrors()Get the current ignoreHttpErrors configuration.Connection.RequestignoreHttpErrors(boolean ignoreHttpErrors)Configures the request to ignore HTTP errors in the response.intmaxBodySize()Get the maximum body size, in bytes.Connection.RequestmaxBodySize(int bytes)Update the maximum body size, in bytes.Parserparser()Get the current parser to use when parsing the document.Connection.Requestparser(Parser parser)Specify the parser to use when parsing the document.java.lang.StringpostDataCharset()Gets the post data character set for x-www-form-urlencoded post dataConnection.RequestpostDataCharset(java.lang.String charset)Sets the post data character set for x-www-form-urlencoded post datajava.net.Proxyproxy()Get the proxy used for this request.Connection.Requestproxy(java.lang.String host, int port)Set the HTTP proxy to use for this request.Connection.Requestproxy(java.net.Proxy proxy)Update the proxy for this request.java.lang.StringrequestBody()Get the current request body.Connection.RequestrequestBody(java.lang.String body)Set a POST (or PUT) request body.javax.net.ssl.SSLSocketFactorysslSocketFactory()Get the current custom SSL socket factory, if any.voidsslSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)Set a custom SSL socket factory.inttimeout()Get the request timeout, in milliseconds.Connection.Requesttimeout(int millis)Update the request timeout.-
Methods inherited from interface org.jsoup.Connection.Base
addHeader, cookie, cookie, cookies, hasCookie, hasHeader, hasHeaderWithValue, header, header, headers, headers, method, method, multiHeaders, removeCookie, removeHeader, url, url
-
-
-
-
Method Detail
-
proxy
java.net.Proxy proxy()
Get the proxy used for this request.- Returns:
- the proxy;
nullif not enabled.
-
proxy
Connection.Request proxy(java.net.Proxy proxy)
Update the proxy for this request.- Parameters:
proxy- the proxy ot use;nullto disable.- Returns:
- this Request, for chaining
-
proxy
Connection.Request proxy(java.lang.String host, int port)
Set the HTTP proxy to use for this request.- Parameters:
host- the proxy hostnameport- the proxy port- Returns:
- this Connection, for chaining
-
timeout
int timeout()
Get the request timeout, in milliseconds.- Returns:
- the timeout in milliseconds.
-
timeout
Connection.Request timeout(int millis)
Update the request timeout.- Parameters:
millis- timeout, in milliseconds- Returns:
- this Request, for chaining
-
maxBodySize
int maxBodySize()
Get the maximum body size, in bytes.- Returns:
- the maximum body size, in bytes.
-
maxBodySize
Connection.Request maxBodySize(int bytes)
Update the maximum body size, in bytes.- Parameters:
bytes- maximum body size, in bytes.- Returns:
- this Request, for chaining
-
followRedirects
boolean followRedirects()
Get the current followRedirects configuration.- Returns:
- true if followRedirects is enabled.
-
followRedirects
Connection.Request followRedirects(boolean followRedirects)
Configures the request to (not) follow server redirects. By default this is true.- Parameters:
followRedirects- true if server redirects should be followed.- Returns:
- this Request, for chaining
-
ignoreHttpErrors
boolean ignoreHttpErrors()
Get the current ignoreHttpErrors configuration.- Returns:
- true if errors will be ignored; false (default) if HTTP errors will cause an IOException to be thrown.
-
ignoreHttpErrors
Connection.Request ignoreHttpErrors(boolean ignoreHttpErrors)
Configures the request to ignore HTTP errors in the response.- Parameters:
ignoreHttpErrors- set to true to ignore HTTP errors.- Returns:
- this Request, for chaining
-
ignoreContentType
boolean ignoreContentType()
Get the current ignoreContentType configuration.- Returns:
- true if invalid content-types will be ignored; false (default) if they will cause an IOException to be thrown.
-
ignoreContentType
Connection.Request ignoreContentType(boolean ignoreContentType)
Configures the request to ignore the Content-Type of the response.- Parameters:
ignoreContentType- set to true to ignore the content type.- Returns:
- this Request, for chaining
-
sslSocketFactory
javax.net.ssl.SSLSocketFactory sslSocketFactory()
Get the current custom SSL socket factory, if any.- Returns:
- custom SSL socket factory if set, null otherwise
-
sslSocketFactory
void sslSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
Set a custom SSL socket factory.- Parameters:
sslSocketFactory- SSL socket factory
-
data
Connection.Request data(Connection.KeyVal keyval)
Add a data parameter to the request- Parameters:
keyval- data to add.- Returns:
- this Request, for chaining
-
data
java.util.Collection<Connection.KeyVal> data()
Get all of the request's data parameters- Returns:
- collection of keyvals
-
requestBody
Connection.Request requestBody(java.lang.String body)
Set a POST (or PUT) request body. Useful when a server expects a plain request body, not a set for URL encoded form key/value pairs. E.g.:If any data key/vals are supplied, they will be sent as URL query params.Jsoup.connect(url) .requestBody(json) .header("Content-Type", "application/json") .post();- Returns:
- this Request, for chaining
-
requestBody
java.lang.String requestBody()
Get the current request body.- Returns:
- null if not set.
-
parser
Connection.Request parser(Parser parser)
Specify the parser to use when parsing the document.- Parameters:
parser- parser to use.- Returns:
- this Request, for chaining
-
parser
Parser parser()
Get the current parser to use when parsing the document.- Returns:
- current Parser
-
postDataCharset
Connection.Request postDataCharset(java.lang.String charset)
Sets the post data character set for x-www-form-urlencoded post data- Parameters:
charset- character set to encode post data- Returns:
- this Request, for chaining
-
postDataCharset
java.lang.String postDataCharset()
Gets the post data character set for x-www-form-urlencoded post data- Returns:
- character set to encode post data
-
-