Class ClientConfiguration

java.lang.Object
com.groiss.http.ClientConfiguration

public class ClientConfiguration extends Object
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 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

      public ClientConfiguration setAcceptSelfSignedCertificates(boolean acceptSelfSignedCertificates)
      Set this property to true if you want to accept self signed certificates.
      Parameters:
      acceptSelfSignedCertificates - the acceptSelfSignedCertificates to set
    • getBaseHeaders

      protected List<Parameter> getBaseHeaders()
      Returns a list of the headers which will be added to each client call.
      Returns:
      the headers to add to client calls
    • addBaseHeaders

      public ClientConfiguration addBaseHeaders(Parameter... headers)
      Add the set of headers which will be added to each client call.
      Parameters:
      headers - the headers used for each client call
    • getBaseParameters

      protected List<Parameter> getBaseParameters()
      Returns a list of the parameters which will be added to each client call.
      Returns:
      the headers to add to client calls
    • addBaseParameters

      public ClientConfiguration addBaseParameters(Parameter... parameters)
      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

      public ClientConfiguration setHandleRedirects(boolean handleRedirects)
      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

      protected String 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

      public ClientConfiguration setBaseUrl(String baseUrl)
      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

      public ClientConfiguration setSocketTimeout(int socketTimeout)
      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

      public ClientConfiguration setConnectTimeout(int connectTimeout)
      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

      protected String getProxyUrl()
      Returns the url to the proxy to be used
      Returns:
      the proxy url
    • setProxyUrl

      public ClientConfiguration setProxyUrl(String proxyUrl)
      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

      public String toString()
      Overrides:
      toString in class Object
    • fieldAsString

      protected String fieldAsString(Field field)