Package org.jsoup.helper
Class HttpConnection.Base<T extends Connection.Base<T>>
java.lang.Object
org.jsoup.helper.HttpConnection.Base<T>
- All Implemented Interfaces:
Connection.Base<T>
- Direct Known Subclasses:
HttpConnection.Request
,HttpConnection.Response
- Enclosing class:
- HttpConnection
private abstract static class HttpConnection.Base<T extends Connection.Base<T>>
extends Object
implements Connection.Base<T>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a header.Get a cookie value by name from this request/response.Set a cookie in this request/response.cookies()
Retrieve all of the request/response cookies as a mapboolean
Check if a cookie is presentboolean
Check if a header is presentboolean
hasHeaderWithValue
(String name, String value) Test if the request has a header with this value (case insensitive).Get the value of a header.Set a header.headers()
Retrieve all of the request/response header names and corresponding values as a map.Get the values of a header.method()
Get the request method, which defaults toGET
method
(Connection.Method method) Set the request methodRetreive all of the headers, keyed by the header name, and with a list of values per header.removeCookie
(String name) Remove a cookie by nameremoveHeader
(String name) Remove headers by name.scanHeaders
(String name) url()
Get the URL of this Request or Response.Set the URL
-
Field Details
-
UnsetUrl
-
url
URL url -
method
Connection.Method method -
headers
-
cookies
-
-
Constructor Details
-
Base
private Base() -
Base
-
-
Method Details
-
url
Description copied from interface:Connection.Base
Get the URL of this Request or Response. For redirected responses, this will be the final destination URL.- Specified by:
url
in interfaceConnection.Base<T extends Connection.Base<T>>
- Returns:
- URL
-
url
Description copied from interface:Connection.Base
Set the URL- Specified by:
url
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
url
- new URL- Returns:
- this, for chaining
-
method
Description copied from interface:Connection.Base
Get the request method, which defaults toGET
- Specified by:
method
in interfaceConnection.Base<T extends Connection.Base<T>>
- Returns:
- method
-
method
Description copied from interface:Connection.Base
Set the request method- Specified by:
method
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
method
- new method- Returns:
- this, for chaining
-
header
Description copied from interface:Connection.Base
Get the value of a header. If there is more than one header value with the same name, the headers are returned comma separated, per rfc2616-sec4.Header names are case-insensitive.
- Specified by:
header
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- name of header (case-insensitive)- Returns:
- value of header, or null if not set.
- See Also:
-
addHeader
Description copied from interface:Connection.Base
Add a header. The header will be added regardless of whether a header with the same name already exists.For compatibility, if the content of the header includes text that cannot be represented by ISO-8859-1, then it should be encoded first per RFC 2047.
- Specified by:
addHeader
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- Name of new headervalue
- Value of new header- Returns:
- this, for chaining
-
headers
Description copied from interface:Connection.Base
Get the values of a header.- Specified by:
headers
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- header name, case-insensitive.- Returns:
- a list of values for this header, or an empty list if not set.
-
header
Description copied from interface:Connection.Base
Set a header. This method will overwrite any existing header with the same case-insensitive name. If there is more than one value for this header, this method will update the first matching header.For compatibility, if the content of the header includes text that cannot be represented by ISO-8859-1, then it should be encoded first per RFC 2047.
- Specified by:
header
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- Name of headervalue
- Value of header- Returns:
- this, for chaining
- See Also:
-
hasHeader
Description copied from interface:Connection.Base
Check if a header is present- Specified by:
hasHeader
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- name of header (case-insensitive)- Returns:
- if the header is present in this request/response
-
hasHeaderWithValue
Test if the request has a header with this value (case insensitive).- Specified by:
hasHeaderWithValue
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- header name (case-insensitive)value
- value (case-insensitive)- Returns:
- if the header and value pair are set in this req/res
-
removeHeader
Description copied from interface:Connection.Base
Remove headers by name. If there is more than one header with this name, they will all be removed.- Specified by:
removeHeader
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- name of header to remove (case-insensitive)- Returns:
- this, for chaining
-
headers
Description copied from interface:Connection.Base
Retrieve all of the request/response header names and corresponding values as a map. For headers with multiple values, only the first header is returned.Note that this is a view of the headers only, and changes made to this map will not be reflected in the request/response object.
- Specified by:
headers
in interfaceConnection.Base<T extends Connection.Base<T>>
- Returns:
- headers
- See Also:
-
multiHeaders
Description copied from interface:Connection.Base
Retreive all of the headers, keyed by the header name, and with a list of values per header.- Specified by:
multiHeaders
in interfaceConnection.Base<T extends Connection.Base<T>>
- Returns:
- a list of multiple values per header.
-
getHeadersCaseInsensitive
-
scanHeaders
-
cookie
Description copied from interface:Connection.Base
Get a cookie value by name from this request/response.Response objects have a simplified cookie model. Each cookie set in the response is added to the response object's cookie key=value map. The cookie's path, domain, and expiry date are ignored.
- Specified by:
cookie
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- name of cookie to retrieve.- Returns:
- value of cookie, or null if not set
-
cookie
Description copied from interface:Connection.Base
Set a cookie in this request/response.- Specified by:
cookie
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- name of cookievalue
- value of cookie- Returns:
- this, for chaining
-
hasCookie
Description copied from interface:Connection.Base
Check if a cookie is present- Specified by:
hasCookie
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- name of cookie- Returns:
- if the cookie is present in this request/response
-
removeCookie
Description copied from interface:Connection.Base
Remove a cookie by name- Specified by:
removeCookie
in interfaceConnection.Base<T extends Connection.Base<T>>
- Parameters:
name
- name of cookie to remove- Returns:
- this, for chaining
-
cookies
Description copied from interface:Connection.Base
Retrieve all of the request/response cookies as a map- Specified by:
cookies
in interfaceConnection.Base<T extends Connection.Base<T>>
- Returns:
- cookies
-