Class AS2HttpClient

java.lang.Object
com.helger.as2lib.util.http.AS2HttpClient

public class AS2HttpClient extends Object
Http connection, Implemented as HttpClient.
Author:
Ziv Harpaz, Philip Helger
  • Constructor Details

  • Method Details

    • setHttpHeader

      public void setHttpHeader(@Nonnull String sName, @Nonnull String sValue)
      Set an HTTP header (replacing existing value). No modification or check on name or value happens.
      Parameters:
      sName - Header name. May not be null.
      sValue - Header value. May not be null.
    • getURL

      @Nonnull public URL getURL() throws AS2Exception
      Returns:
      The URL to send to. Should be the same as the one passed in the constructor. Never null.
      Throws:
      AS2Exception - in case of error (e.g. if the URI could not be converted to a URL).
    • send

      @Nonnegative public long send(@Nonnull @WillClose InputStream aISToSend, @Nullable com.helger.mail.cte.EContentTransferEncoding eCTE, @Nullable IHTTPOutgoingDumper aOutgoingDumper, @Nonnull AS2ResourceHelper aResHelper) throws IOException
      Parameters:
      aISToSend - InputStream to send. May not be null.
      eCTE - Content-Transfer-Encoding to be used. May not be null.
      aOutgoingDumper - Optional outgoing dumper
      aResHelper - Resource helper
      Returns:
      bytes sent. Must be ≥ 0.
      Throws:
      IOException - In case of error
    • getInputStream

      public InputStream getInputStream() throws AS2Exception, IOException
      Get InputStream
      Returns:
      InputStream to read response body from
      Throws:
      AS2Exception - in case of error
      IOException - in case of IO error
    • getResponseCode

      public int getResponseCode() throws AS2Exception
      Returns:
      response HTTP Status as int
      Throws:
      AS2Exception - in case of error
    • getResponseMessage

      public String getResponseMessage() throws AS2Exception
      Returns:
      the response message
      Throws:
      AS2Exception - in case of error
    • getResponseHeaderFields

      @Nonnull @ReturnsMutableCopy public com.helger.commons.http.HttpHeaderMap getResponseHeaderFields() throws AS2Exception
      Throws:
      AS2Exception
    • disconnect

      public void disconnect()
      Close the connection
    • isErrorResponseCode

      public static boolean isErrorResponseCode(int nResponseCode)
      This method determines if something is an HTTP error or not. The following HTTP status codes are interpreted as success: 200, 201, 202, 204 and 206.
      Parameters:
      nResponseCode - The HTTP status code to check.
      Returns:
      true if it is an error, false on success.