Package org.jsoup
Interface Connection.Request
- All Superinterfaces:
-
Connection.Base<Connection.Request>
- All Known Implementing Classes:
-
HttpConnection.Request
- Enclosing interface:
-
Connection
Represents a HTTP request.
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable RequestAuthenticator
auth()
Get the RequestAuthenticator, if any, that will be used on this request.default Connection.Request
auth
(@Nullable RequestAuthenticator authenticator) Set the authenticator to use for this request.Collection
<Connection.KeyVal> 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.String
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 data@Nullable Proxy
proxy()
Get the proxy used for this request.proxy
(String host, int port) Set the HTTP proxy to use for this request.Update the proxy for this request.@Nullable String
Get the current request body.requestBody
(@Nullable String body) Set a POST (or PUT) request body.@Nullable SSLSocketFactory
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 interface org.jsoup.Connection.Base
addHeader, cookie, cookie, cookies, hasCookie, hasHeader, hasHeaderWithValue, header, header, headers, headers, method, method, multiHeaders, removeCookie, removeHeader, url, url
-
Method Details
-
proxy
@Nullable Proxy proxy()Get the proxy used for this request.- Returns:
-
the proxy;
null
if not enabled.
-
proxy
Update the proxy for this request.- Parameters:
-
proxy
- the proxy ot use;null
to disable. - Returns:
- this Request, for chaining
-
proxy
Set the HTTP proxy to use for this request.- Parameters:
-
host
- the proxy hostname -
port
- the proxy port - Returns:
- this Connection, for chaining
-
timeout
int timeout()Get the request timeout, in milliseconds.- Returns:
- the timeout in milliseconds.
-
timeout
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
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
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
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
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
@Nullable SSLSocketFactory sslSocketFactory()Get the current custom SSL socket factory, if any.- Returns:
- custom SSL socket factory if set, null otherwise
-
sslSocketFactory
Set a custom SSL socket factory.- Parameters:
-
sslSocketFactory
- SSL socket factory
-
data
Add a data parameter to the request- Parameters:
-
keyval
- data to add. - Returns:
- this Request, for chaining
-
data
Collection<Connection.KeyVal> data()Get all of the request's data parameters- Returns:
- collection of keyvals
-
requestBody
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.:Jsoup.connect(url) .requestBody(json) .header("Content-Type", "application/json") .post();
- Parameters:
-
body
- to use as the request body. Set to null to clear a previously set body. - Returns:
- this Request, for chaining
-
requestBody
@Nullable String requestBody()Get the current request body.- Returns:
- null if not set.
-
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
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
String postDataCharset()Gets the post data character set for x-www-form-urlencoded post data- Returns:
- character set to encode post data
-
auth
Set the authenticator to use for this request. SeeConnection.auth(authenticator)
for examples and implementation notes.- Parameters:
-
authenticator
- the authenticator - Returns:
- this Request, for chaining.
- Since:
- 1.17.1
-
auth
Get the RequestAuthenticator, if any, that will be used on this request.- Returns:
-
the RequestAuthenticator, or
null
if not set - Since:
- 1.17.1
-