Class HttpModule

java.lang.Object
ecmwf.common.ectrans.TransferModule
ecmwf.common.ectrans.module.HttpModule
All Implemented Interfaces:
Closeable, AutoCloseable

public final class HttpModule extends TransferModule
The Class HttpModule.
  • Constructor Details

    • HttpModule

      public HttpModule()
  • Method Details

    • getStatus

      public String getStatus()
      Gets the status.
      Overrides:
      getStatus in class TransferModule
      Returns:
      the status
    • getPort

      public int getPort(ECtransSetup setup)
      Gets the port.
      Overrides:
      getPort in class TransferModule
      Parameters:
      setup - the setup
      Returns:
      the port
    • updateSocketStatistics

      public void updateSocketStatistics() throws IOException
      Update socket statistics.
      Overrides:
      updateSocketStatistics in class TransferModule
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • connect

      public void connect(String location, ECtransSetup setup) throws IOException
      Connect.
      Specified by:
      connect in class TransferModule
      Parameters:
      location - the location
      setup - the setup
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • getConnectedRemoteAddress

      public String getConnectedRemoteAddress()
      Gets the real IP address of the remote host this module most recently connected to, if the underlying protocol implementation tracks it. This can differ from the configured Host address for anycast/load-balanced endpoints (e.g. Amazon S3, Google Cloud Storage), where a fresh DNS lookup of the same hostname performed later (e.g. for "Live ECPDS Earth" geolocation) may return a different IP than the one actually used for the transfer. Overridden by modules that track this (currently s3 and http/https); other modules keep the default of null, meaning the configured Host address should be used instead. Returns the real IP address of the remote host most recently connected to, tracked via the connection socket factories. Preferred over resolving the Host address via DNS again later, since some HTTP endpoints (e.g. anycast/load-balanced services such as Google Cloud Storage) may resolve to a different IP on every lookup.
      Overrides:
      getConnectedRemoteAddress in class TransferModule
      Returns:
      the remote IP address, or null if not tracked or not yet connected
    • del

      public void del(String name) throws IOException
      Del.
      Specified by:
      del in class TransferModule
      Parameters:
      name - the name
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • put

      public OutputStream put(String name, long posn, long size) throws IOException
      Put.
      Specified by:
      put in class TransferModule
      Parameters:
      name - the name
      posn - the posn
      size - the size
      Returns:
      the output stream
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • put

      public boolean put(InputStream input, String name, long posn, long size) throws IOException
      Put.
      Overrides:
      put in class TransferModule
      Parameters:
      input - the input
      name - the name
      posn - the posn
      size - the size
      Returns:
      true, if successful
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • get

      public InputStream get(String name, long posn) throws IOException
      Gets the.
      Specified by:
      get in class TransferModule
      Parameters:
      name - the name
      posn - the posn
      Returns:
      the input stream
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • size

      public long size(String name) throws IOException
      Size.
      Specified by:
      size in class TransferModule
      Parameters:
      name - the name
      Returns:
      the long
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • list

      public void list(String directory, String pattern, OutputStream out) throws IOException
      List.
      Overrides:
      list in class TransferModule
      Parameters:
      directory - the directory
      pattern - the pattern
      out - the out
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • listAsStringArray

      public String[] listAsStringArray(String directory, String pattern) throws IOException
      List as string array.
      Overrides:
      listAsStringArray in class TransferModule
      Parameters:
      directory - the directory
      pattern - the pattern
      Returns:
      the string[]
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • resolveHref

      public static String resolveHref(String currentUrl, String href) throws URISyntaxException
      Resolves an href relative to the current URL or path.
      Parameters:
      currentUrl - the current URL or path (can be root-relative or full URL)
      href - the href to resolve (can be relative or absolute)
      Returns:
      the resolved path or URL
      Throws:
      URISyntaxException - if the URL is invalid
    • close

      public void close() throws IOException
      Close.
      Throws:
      IOException - Signals that an I/O exception has occurred.