Package com.groiss.http
Class ClientConfiguration
java.lang.Object
com.groiss.http.ClientConfiguration
With this class the
Client
for HTTP based communication can be configured. It is designed to be used for properties
which are the very same for each (or most) of the requests of your use case - e.g. an authorization token in
the header.
So the intended usage is that such a configuration is created once and will then be used for each client you
need to do your communications.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Returns is support for self signed certificates is neededaddBaseHeaders
(Parameter... headers) Add the set of headers which will be added to each client call.addBaseParameters
(Parameter... parameters) Add the set of parameters which will be added to each client call.protected String
fieldAsString
(Field field) Returns a list of the headers which will be added to each client call.Returns a list of the parameters which will be added to each client call.protected String
Returns the url prefix to be added in front of every url used for a client call.protected int
Returns the value for the connect timeout, i.e. the time the client waits for establishing a connection.protected String
Returns the url to the proxy to be usedprotected int
Returns the value for the socket timeout, i.e. the time the client waits for a response.protected boolean
Returns if support of handling redirects is neededsetAcceptSelfSignedCertificates
(boolean acceptSelfSignedCertificates) Set this property to true if you want to accept self signed certificates.setBaseUrl
(String baseUrl) Sets the url prefix to be added in front of every url used for a client call.setConnectTimeout
(int connectTimeout) Sets the connect timeout of a client request, i.e. the time the client waits for establishing a connection.setHandleRedirects
(boolean handleRedirects) Set this property to true if you need to support redirects in the response of a client call.setProxyUrl
(String proxyUrl) Set the url to the proxy.setSocketTimeout
(int socketTimeout) Sets the socket timeout of a client request, i.e. the time the client waits for a response.toString()
-
Constructor Details
-
ClientConfiguration
public ClientConfiguration()
-
-
Method Details
-
acceptSelfSignedCertificates
protected boolean acceptSelfSignedCertificates()Returns is support for self signed certificates is needed- Returns:
- true if support for self signed certificates is needed, false otherwise
-
setAcceptSelfSignedCertificates
Set this property to true if you want to accept self signed certificates.- Parameters:
acceptSelfSignedCertificates
- the acceptSelfSignedCertificates to set
-
getBaseHeaders
Returns a list of the headers which will be added to each client call.- Returns:
- the headers to add to client calls
-
addBaseHeaders
Add the set of headers which will be added to each client call.- Parameters:
headers
- the headers used for each client call
-
getBaseParameters
Returns a list of the parameters which will be added to each client call.- Returns:
- the headers to add to client calls
-
addBaseParameters
Add the set of parameters which will be added to each client call.- Parameters:
parameters
- the parameters used for each client call
-
handleRedirects
protected boolean handleRedirects()Returns if support of handling redirects is needed- Returns:
- true is redirect handling is needed, false otherwise
-
setHandleRedirects
Set this property to true if you need to support redirects in the response of a client call.- Parameters:
handleRedirects
- the handleRedirects to set
-
getBaseUrl
Returns the url prefix to be added in front of every url used for a client call.- Returns:
- the url prefix to be added in client call urls
-
setBaseUrl
Sets the url prefix to be added in front of every url used for a client call.- Parameters:
baseUrl
- the baseUrl to set
-
getSocketTimeout
protected int getSocketTimeout()Returns the value for the socket timeout, i.e. the time the client waits for a response. The value is in milliseconds.- Returns:
- the value for socket timeout.
-
setSocketTimeout
Sets the socket timeout of a client request, i.e. the time the client waits for a response. The value is in milliseconds. If 0 is set the default socket timeout will be left unchanged.- Parameters:
socketTimeout
- the socket timeout to set
-
getConnectTimeout
protected int getConnectTimeout()Returns the value for the connect timeout, i.e. the time the client waits for establishing a connection. The value is in milliseconds.- Returns:
- the value for connect timeout.
-
setConnectTimeout
Sets the connect timeout of a client request, i.e. the time the client waits for establishing a connection. The value is in milliseconds. If 0 is set the default connect timeout will be left unchanged.- Parameters:
connectTimeout
- the connect timeout to set
-
getProxyUrl
Returns the url to the proxy to be used- Returns:
- the proxy url
-
setProxyUrl
Set the url to the proxy. If no protocol is defined http will be used. If no port is defined ????- Parameters:
proxyUrl
- the url to the proxy
-
toString
-
fieldAsString
-