Class GXConnection

java.lang.Object
org.gcube.common.gxhttp.reference.GXConnection

public class GXConnection extends Object
A remote connection for a GXHTTPStringRequest.
Author:
Manuele Simi (ISTI-CNR), Luca Frosini (ISTI-CNR)
  • Field Details

    • APPLICATION_JSON_CHARSET_UTF_8

      public static final String APPLICATION_JSON_CHARSET_UTF_8
      The application/json;charset=UTF-8 content type.
      See Also:
    • PATH_SEPARATOR

      public static final String PATH_SEPARATOR
      The path separator.
      See Also:
    • PARAM_STARTER

      public static final String PARAM_STARTER
      The parameter starter.
      See Also:
    • PARAM_EQUALS

      public static final String PARAM_EQUALS
      The parameter equals.
      See Also:
    • PARAM_SEPARATOR

      public static final String PARAM_SEPARATOR
      The parameter separator.
      See Also:
    • UTF8

      public static final String UTF8
      The UTF-8 charset.
      See Also:
    • logger

      protected static final org.slf4j.Logger logger
      The logger.
    • address

      protected final String address
      The address of the remote service.
    • path

      protected String path
      The path of the remote service.
    • agent

      protected String agent
      The path of the remote service.
  • Constructor Details

    • GXConnection

      public GXConnection(String address)
      Creates a new connection.
      Parameters:
      address - the address of the remote service
  • Method Details

    • addPath

      protected void addPath(String pathPart) throws UnsupportedEncodingException
      Adds a path part to the connection.
      Parameters:
      pathPart - the path part to add
      Throws:
      UnsupportedEncodingException - if the encoding is not supported
    • send

      Sends the request with the given method
      Parameters:
      method - the HTTP method
      Returns:
      the connection
      Throws:
      Exception - if an error occurs
    • setAgent

      protected void setAgent(String agent)
      Sets the agent for the connection.
      Parameters:
      agent - the agent
    • setPathParameters

      public void setPathParameters(String parameters)
      Sets the path parameters for the connection.
      Parameters:
      parameters - the parameters
    • setQueryParameters

      public void setQueryParameters(String parameters)
      Sets the query parameters for the connection.
      Parameters:
      parameters - the parameters
    • reset

      public void reset()
      Resets the connection.
    • addBody

      public void addBody(String body)
      The body of the request.
      Parameters:
      body - the body
    • addBodyAsStream

      public void addBodyAsStream(InputStream bodyAsStream)
      Parameters:
      bodyAsStream - the stream to set as input
    • setProperty

      public void setProperty(String name, String value)
      Adds a property as header.
      Parameters:
      name - the name of the property
      value - the value of the property