public class JSONRPC2SessionOptions extends Object
JSONRPC2Session
uses. To apply different ones instantiate a new settings instance, set the
desired ones to your liking, and then pass
it to your JSONRPC2Session
instance.
Overview of the available session options:
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_ACCEPT_COOKIES
The default HTTP cookie acceptance policy.
|
static String[] |
DEFAULT_ALLOWED_RESPONSE_CONTENT_TYPES
The default allowed "Content-Type" (MIME) header values of HTTP
responses.
|
static int |
DEFAULT_CONNECT_TIMEOUT
The default HTTP connect timeout.
|
static String |
DEFAULT_CONTENT_TYPE
The default "Content-Type" (MIME) header value of HTTP POST
requests.
|
static boolean |
DEFAULT_ENABLE_COMPRESSION
The default HTTP GZIP and DEFLATE compression enable policy.
|
static boolean |
DEFAULT_IGNORE_VERSION
The default policy for version 2.0 checking.
|
static String |
DEFAULT_ORIGIN
The default CORS "Origin" header value.
|
static boolean |
DEFAULT_PARSE_NON_STD_ATTRIBUTES
The default policy for parsing non-standard attributes in JSON-RPC
2.0 messages.
|
static boolean |
DEFAULT_PRESERVE_OBJECT_MEMBER_ORDER
The default policy for preserving the order of parsed JSON object
members.
|
static int |
DEFAULT_READ_TIMEOUT
The default HTTP read timeout.
|
static boolean |
DEFAULT_TRUST_ALL
The default policy for trusting self-signed certificates.
|
Constructor and Description |
---|
JSONRPC2SessionOptions()
Creates a new default JSON-RPC 2.0 client session options instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
acceptCookies()
Returns
true if HTTP cookies are accepted, else
false if they are ignored. |
void |
acceptCookies(boolean acceptCookies)
Specifies whether to accept HTTP cookies contained in the server
response.
|
boolean |
enableCompression()
Checks if HTTP response compression using GZIP or DEFLATE content
encoding is enabled or disabled.
|
void |
enableCompression(boolean enable)
Enables or disables HTTP response compression using GZIP or DEFLATE
content encoding.
|
String[] |
getAllowedResponseContentTypes()
Gets the allowed "Content-Type" (MIME) header values of HTTP
responses.
|
int |
getConnectTimeout()
Gets the HTTP connect timeout.
|
String |
getOrigin()
Gets the value of the "Origin" HTTP header.
|
Proxy |
getProxy()
Gets the HTTP proxy.
|
int |
getReadTimeout()
Gets the HTTP read timeout.
|
String |
getRequestContentType()
Gets the value of the "Content-Type" (MIME) header for HTTP POST
requests.
|
boolean |
ignoresVersion()
Returns
true if strict parsing of received JSON-RPC 2.0
responses is disabled and the "jsonrpc" version attribute is not
checked for "2.0" equality. |
void |
ignoreVersion(boolean ignore)
Controls the strictness of the JSON-RPC 2.0 response parser.
|
boolean |
isAllowedResponseContentType(String contentType)
Checks if the specified HTTP "Content-Type" (MIME) header value is
allowed.
|
void |
parseNonStdAttributes(boolean enable)
Specifies whether to parse non-standard attributes found in JSON-RPC
2.0 responses.
|
boolean |
parsesNonStdAttributes()
Returns
true if non-standard attributes in JSON-RPC 2.0
responses are parsed. |
void |
preserveParseOrder(boolean preserve)
Controls the behaviour of the JSON parser when processing object
members in JSON-RPC 2.0 response results.
|
boolean |
preservesParseOrder()
Returns
true if the member order of parsed JSON objects in
JSON-RPC 2.0 response results is preserved. |
void |
setAllowedResponseContentTypes(String[] contentTypes)
Sets the allowed "Content-Type" (MIME) header values of HTTP
responses.
|
void |
setConnectTimeout(int timeout)
Sets the HTTP connect timeout.
|
void |
setOrigin(String origin)
Sets the value of the "Origin" HTTP header.
|
void |
setProxy(Proxy proxy)
Sets an HTTP proxy.
|
void |
setReadTimeout(int timeout)
Sets the HTTP read timeout.
|
void |
setRequestContentType(String contentType)
Sets the value of the HTTP "Content-Type" (MIME) header.
|
void |
trustAllCerts(boolean trustAll)
Controls checking of X.509 certificates presented by the server when
establishing a secure HTTPS connection.
|
boolean |
trustsAllCerts()
Returns
true if all X.509 certificates presented by the web
server will be trusted, including self-signed ones. |
public static final String DEFAULT_CONTENT_TYPE
application/json
.public static final String[] DEFAULT_ALLOWED_RESPONSE_CONTENT_TYPES
application/json
and text/plain
.public static final String DEFAULT_ORIGIN
null
(none).public static final boolean DEFAULT_ACCEPT_COOKIES
public static final boolean DEFAULT_PRESERVE_OBJECT_MEMBER_ORDER
false
(no preserve).public static final boolean DEFAULT_IGNORE_VERSION
false
(strict checking).public static final boolean DEFAULT_PARSE_NON_STD_ATTRIBUTES
false
(non-standard attributes ignored).public static final int DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_READ_TIMEOUT
public static final boolean DEFAULT_ENABLE_COMPRESSION
public static final boolean DEFAULT_TRUST_ALL
false
(self-signed certificates not accepted).public JSONRPC2SessionOptions()
The "Content-Type" (MIME) header value of HTTP POST requests will
be set to "application/json". To change it use
setRequestContentType(java.lang.String)
.
"Origin" HTTP headers will not be added. To add one use
setOrigin(java.lang.String)
.
HTTP cookies will be ignored. To accept cookies, e.g. for
browser-like session handling, use acceptCookies
.
The allowed HTTP response content types are set to
"application/json" and "text/plain". To change them use
setAllowedResponseContentTypes(java.lang.String[])
.
The parse order of JSON object members in JSON-RPC 2.0 response
results will not be preserved. To change this behaviour use
preserveParseOrder(boolean)
.
Strict 2.0 version checking will be performed. To ignore the
JSON-RPC version attribute use ignoreVersion(boolean)
.
HTTP connect timeouts will be disabled. To specify a value use
setConnectTimeout(int)
.
HTTP read timeouts will be disabled. To specify a value use
setReadTimeout(int)
.
No proxy is used. To specify one use setProxy(java.net.Proxy)
.
HTTP response compression (GZIP or DEFLATE) is disabled. To
enable it use enableCompression(boolean)
.
Self-signed X.509 certificates presented by the JSON-RPC 2.0
server will not be accepted. To relax certificate cheking use
trustAllCerts(boolean)
.
public String getRequestContentType()
null
if the
header is not added to HTTP POST requests.public void setRequestContentType(String contentType)
contentType
- The value of the "Content-Type" (MIME) header
in HTTP POST requests, null
to suppress
the header.public String getOrigin()
This header can be used to simulate Cross-Origin Resource Sharing (CORS) requests from a browser.
null
if the header is not
added to HTTP requests.public void setOrigin(String origin)
This header can be used to simulate Cross-Origin Resource Sharing (CORS) requests from a browser.
origin
- The value of the "Origin" header in HTTP requests,
null
to suppress the header.public boolean acceptCookies()
true
if HTTP cookies are accepted, else
false
if they are ignored.true
if HTTP cookies are accepted, else
false
.public void acceptCookies(boolean acceptCookies)
acceptCookies
- true
to accept HTTP cookies, else
false
to ignore them.public String[] getAllowedResponseContentTypes()
The JSONRPC2Session.send(...)
method will throw a
JSONRPC2SessionException.UNEXPECTED_CONTENT_TYPE
if the
received HTTP response "Content-Type" (MIME) header value is not
allowed.
null
any header value
is allowed.public void setAllowedResponseContentTypes(String[] contentTypes)
The JSONRPC2Session.send(...)
method will throw a
JSONRPC2SessionException.UNEXPECTED_CONTENT_TYPE
if the
received HTTP response "Content-Type" (MIME) header value is not
allowed.
contentTypes
- The allowed header values, null
to allow
any header value.public boolean isAllowedResponseContentType(String contentType)
contentType
- The "Content-Type" (MIME) header value.true
if the content type is allowed, else
false
.public boolean preservesParseOrder()
true
if the member order of parsed JSON objects in
JSON-RPC 2.0 response results is preserved.true
if the parse order of JSON object members is
preserved, else false
.public void preserveParseOrder(boolean preserve)
java.util.HashMap
in a
non-deterministic order. To preserve the original parse order pass a
boolean true
to this method. Note that this will slow down
parsing and retrieval performance somewhat.preserve
- If true
the parse order of JSON object
members will be preserved, else not.public boolean ignoresVersion()
true
if strict parsing of received JSON-RPC 2.0
responses is disabled and the "jsonrpc" version attribute is not
checked for "2.0" equality. Returns false
if received
JSON-RPC 2.0 responses must strictly conform to the JSON-RPC 2.0
specification.true
if the "jsonrpc":"2.0"
version
attribute is ignored, false
if parsing is strict.public void ignoreVersion(boolean ignore)
true
parsing is relaxed and the "jsonrpc" version attribute will not be
checked for "2.0" equality.ignore
- true
to ignore the 2.0 "jsonrpc":"2.0"
version attribute, false
for strict parsing.public void parseNonStdAttributes(boolean enable)
enable
- true
to parse non-standard attributes, else
false
.public boolean parsesNonStdAttributes()
true
if non-standard attributes in JSON-RPC 2.0
responses are parsed.true
if non-standard attributes are parsed, else
false
.public void setConnectTimeout(int timeout)
timeout
- The HTTP connect timeout, in milliseconds. Zero
implies the option is disabled (timeout of infinity).public int getConnectTimeout()
public void setReadTimeout(int timeout)
timeout
- The HTTP read timeout, in milliseconds. Zero implies
the option is disabled (timeout of infinity).public int getReadTimeout()
public void setProxy(Proxy proxy)
proxy
- The HTTP proxy to use, null
if none.public Proxy getProxy()
null
if none.public void enableCompression(boolean enable)
enable
- If true
HTTP compression will be enabled,
else compression will be disabled.public boolean enableCompression()
true
if HTTP compression is enabled, else
false
.public void trustAllCerts(boolean trustAll)
false
this security check is disabled and all
certificates will be trusted, including self-signed ones. Use this
for testing and development purposes only.trustAll
- If true
all X.509 certificates presented by
the web server will be trusted, including self-signed
ones. If false
the default security policy
will be restored.public boolean trustsAllCerts()
true
if all X.509 certificates presented by the web
server will be trusted, including self-signed ones. If false
the default security policy applies.true
if all X.509 certificates are trusted, else
false
.Copyright © 2016 The Transaction Company. All Rights Reserved.