Package org.jsoup.helper
Class HttpConnection.Request
- All Implemented Interfaces:
Connection.Base<Connection.Request>
,Connection.Request
- Enclosing class:
HttpConnection
public static class HttpConnection.Request
extends HttpConnection.Base<Connection.Request>
implements Connection.Request
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate RequestAuthenticator
private String
private CookieManager
private final Collection
<Connection.KeyVal> private boolean
private boolean
private boolean
private boolean
private int
private Parser
private boolean
private String
private Proxy
private Progress
<Connection.Response> private SSLSocketFactory
private int
Fields inherited from class org.jsoup.helper.HttpConnection.Base
cookies, headers, method, url
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauth()
Get the RequestAuthenticator, if any, that will be used on this request.auth
(RequestAuthenticator authenticator) Set the authenticator to use for this request.(package private) CookieManager
data()
Get all of the request's data parametersdata
(Connection.KeyVal keyval) Add a data parameter to the requestboolean
Get the current followRedirects configuration.followRedirects
(boolean followRedirects) Configures the request to (not) follow server redirects.boolean
Get the current ignoreContentType configuration.ignoreContentType
(boolean ignoreContentType) Configures the request to ignore the Content-Type of the response.boolean
Get the current ignoreHttpErrors configuration.ignoreHttpErrors
(boolean ignoreHttpErrors) Configures the request to ignore HTTP errors in the response.int
Get the maximum body size, in bytes.maxBodySize
(int bytes) Update the maximum body size, in bytes.parser()
Get the current parser to use when parsing the document.Specify the parser to use when parsing the document.Gets the post data character set for x-www-form-urlencoded post datapostDataCharset
(String charset) Sets the post data character set for x-www-form-urlencoded post dataproxy()
Get the proxy used for this request.Set the HTTP proxy to use for this request.Update the proxy for this request.Get the current request body.requestBody
(String body) Set a POST (or PUT) request body.Get the current custom SSL socket factory, if any.void
sslSocketFactory
(SSLSocketFactory sslSocketFactory) Set a custom SSL socket factory.int
timeout()
Get the request timeout, in milliseconds.timeout
(int millis) Update the request timeout.Methods inherited from class org.jsoup.helper.HttpConnection.Base
addHeader, cookie, cookie, cookies, hasCookie, hasHeader, hasHeaderWithValue, header, header, headers, headers, method, method, multiHeaders, removeCookie, removeHeader, url, url
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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
-
Field Details
-
proxy
-
timeoutMilliseconds
private int timeoutMilliseconds -
maxBodySizeBytes
private int maxBodySizeBytes -
followRedirects
private boolean followRedirects -
data
-
body
-
ignoreHttpErrors
private boolean ignoreHttpErrors -
ignoreContentType
private boolean ignoreContentType -
parser
-
parserDefined
private boolean parserDefined -
postDataCharset
-
sslSocketFactory
-
cookieManager
-
authenticator
-
responseProgress
-
executing
private volatile boolean executing
-
-
Constructor Details
-
Request
Request() -
Request
Request(HttpConnection.Request copy)
-
-
Method Details
-
proxy
Description copied from interface:Connection.Request
Get the proxy used for this request.- Specified by:
proxy
in interfaceConnection.Request
- Returns:
- the proxy;
null
if not enabled.
-
proxy
Description copied from interface:Connection.Request
Update the proxy for this request.- Specified by:
proxy
in interfaceConnection.Request
- Parameters:
proxy
- the proxy ot use;null
to disable.- Returns:
- this Request, for chaining
-
proxy
Description copied from interface:Connection.Request
Set the HTTP proxy to use for this request.- Specified by:
proxy
in interfaceConnection.Request
- Parameters:
host
- the proxy hostnameport
- the proxy port- Returns:
- this Connection, for chaining
-
timeout
public int timeout()Description copied from interface:Connection.Request
Get the request timeout, in milliseconds.- Specified by:
timeout
in interfaceConnection.Request
- Returns:
- the timeout in milliseconds.
-
timeout
Description copied from interface:Connection.Request
Update the request timeout.- Specified by:
timeout
in interfaceConnection.Request
- Parameters:
millis
- timeout, in milliseconds- Returns:
- this Request, for chaining
-
maxBodySize
public int maxBodySize()Description copied from interface:Connection.Request
Get the maximum body size, in bytes.- Specified by:
maxBodySize
in interfaceConnection.Request
- Returns:
- the maximum body size, in bytes.
-
maxBodySize
Description copied from interface:Connection.Request
Update the maximum body size, in bytes.- Specified by:
maxBodySize
in interfaceConnection.Request
- Parameters:
bytes
- maximum body size, in bytes.- Returns:
- this Request, for chaining
-
followRedirects
public boolean followRedirects()Description copied from interface:Connection.Request
Get the current followRedirects configuration.- Specified by:
followRedirects
in interfaceConnection.Request
- Returns:
- true if followRedirects is enabled.
-
followRedirects
Description copied from interface:Connection.Request
Configures the request to (not) follow server redirects. By default this is true.- Specified by:
followRedirects
in interfaceConnection.Request
- Parameters:
followRedirects
- true if server redirects should be followed.- Returns:
- this Request, for chaining
-
ignoreHttpErrors
public boolean ignoreHttpErrors()Description copied from interface:Connection.Request
Get the current ignoreHttpErrors configuration.- Specified by:
ignoreHttpErrors
in interfaceConnection.Request
- Returns:
- true if errors will be ignored; false (default) if HTTP errors will cause an IOException to be thrown.
-
sslSocketFactory
Description copied from interface:Connection.Request
Get the current custom SSL socket factory, if any.- Specified by:
sslSocketFactory
in interfaceConnection.Request
- Returns:
- custom SSL socket factory if set, null otherwise
-
sslSocketFactory
Description copied from interface:Connection.Request
Set a custom SSL socket factory.- Specified by:
sslSocketFactory
in interfaceConnection.Request
- Parameters:
sslSocketFactory
- SSL socket factory
-
ignoreHttpErrors
Description copied from interface:Connection.Request
Configures the request to ignore HTTP errors in the response.- Specified by:
ignoreHttpErrors
in interfaceConnection.Request
- Parameters:
ignoreHttpErrors
- set to true to ignore HTTP errors.- Returns:
- this Request, for chaining
-
ignoreContentType
public boolean ignoreContentType()Description copied from interface:Connection.Request
Get the current ignoreContentType configuration.- Specified by:
ignoreContentType
in interfaceConnection.Request
- Returns:
- true if invalid content-types will be ignored; false (default) if they will cause an IOException to be thrown.
-
ignoreContentType
Description copied from interface:Connection.Request
Configures the request to ignore the Content-Type of the response.- Specified by:
ignoreContentType
in interfaceConnection.Request
- Parameters:
ignoreContentType
- set to true to ignore the content type.- Returns:
- this Request, for chaining
-
data
Description copied from interface:Connection.Request
Add a data parameter to the request- Specified by:
data
in interfaceConnection.Request
- Parameters:
keyval
- data to add.- Returns:
- this Request, for chaining
-
data
Description copied from interface:Connection.Request
Get all of the request's data parameters- Specified by:
data
in interfaceConnection.Request
- Returns:
- collection of keyvals
-
requestBody
Description copied from interface:Connection.Request
Set a POST (or PUT) request body. Useful when a server expects a plain request body, not a set of 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();
- Specified by:
requestBody
in interfaceConnection.Request
- Parameters:
body
- to use as the request body. Set to null to clear a previously set body.- Returns:
- this Request, for chaining
-
requestBody
Description copied from interface:Connection.Request
Get the current request body.- Specified by:
requestBody
in interfaceConnection.Request
- Returns:
- null if not set.
-
parser
Description copied from interface:Connection.Request
Specify the parser to use when parsing the document.- Specified by:
parser
in interfaceConnection.Request
- Parameters:
parser
- parser to use.- Returns:
- this Request, for chaining
-
parser
Description copied from interface:Connection.Request
Get the current parser to use when parsing the document.- Specified by:
parser
in interfaceConnection.Request
- Returns:
- current Parser
-
postDataCharset
Description copied from interface:Connection.Request
Sets the post data character set for x-www-form-urlencoded post data- Specified by:
postDataCharset
in interfaceConnection.Request
- Parameters:
charset
- character set to encode post data- Returns:
- this Request, for chaining
-
postDataCharset
Description copied from interface:Connection.Request
Gets the post data character set for x-www-form-urlencoded post data- Specified by:
postDataCharset
in interfaceConnection.Request
- Returns:
- character set to encode post data
-
cookieManager
CookieManager cookieManager() -
auth
Description copied from interface:Connection.Request
Set the authenticator to use for this request. SeeConnection.auth(authenticator)
for examples and implementation notes.- Specified by:
auth
in interfaceConnection.Request
- Parameters:
authenticator
- the authenticator- Returns:
- this Request, for chaining.
-
auth
Description copied from interface:Connection.Request
Get the RequestAuthenticator, if any, that will be used on this request.- Specified by:
auth
in interfaceConnection.Request
- Returns:
- the RequestAuthenticator, or
null
if not set
-