Interface INet

All Known Implementing Classes:
Net

public interface INet
Convenience network utility interface to issue common GET/POST (http or https) queries that return text contents. The primary network utility class in this package implements this interface.
See Also:
  • Method Details

    • setUserAgent

      void setUserAgent(String userAgent)
      Parameters:
      userAgent - a user-agent
    • getUserAgent

      String getUserAgent()
      Returns:
      the user-agent
    • setConnectTimeout

      void setConnectTimeout(int timeout)
      Parameters:
      timeout - in milliseconds
    • getConnectTimeout

      int getConnectTimeout()
      Returns:
      timeout in milliseconds
    • setReadTimeout

      void setReadTimeout(int timeout)
      Parameters:
      timeout - timeout in milliseconds
    • getReadTimeout

      int getReadTimeout()
      Returns:
      timeout in milliseconds
    • setWriteTimeout

      void setWriteTimeout(int timeout)
      Parameters:
      timeout - timeout in milliseconds
    • getWriteTimeout

      int getWriteTimeout()
      Returns:
      timeout in milliseconds
    • getSecureSocketInfo

      SecureSocketInfo getSecureSocketInfo()
      Returns:
      optional secure socket customization information
    • setSecureSocketInfo

      void setSecureSocketInfo(SecureSocketInfo info)
      Parameters:
      info - optional secure socket customization information
    • duplicate

      INet duplicate()
      Duplicate this object to perform safe parameter update.
      Returns:
      a new net object with the same properties as this object (timeouts, user-agent, etc.)
    • query

      String query(String url, Map<String,String> parameters, Map<String,String> serverHeaders) throws IOException
      Perform an http GET request.
      Parameters:
      url - url with optional parameters
      parameters - optional additional url parameters
      serverHeaders - optional map whose keys indicate response headers to retrieve
      Returns:
      the server response
      Throws:
      IOException - on error
    • query

      String query(String url, Map<String,String> parameters) throws IOException
      Perform an http GET request.
      Parameters:
      url - url with optional parameters
      parameters - optional additional url parameters
      Returns:
      the server response
      Throws:
      IOException - on error
    • query

      String query(String url) throws IOException
      Perform an http GET request.
      Parameters:
      url - url with optional parameters
      Returns:
      the server response
      Throws:
      IOException - on error
    • queryBinary

      byte[] queryBinary(String url, Map<String,String> urlParams, Map<String,String> serverHeaders, IProgressCallback progressCallback) throws IOException
      Perform an http GET request.
      Parameters:
      url - url with optional parameters
      urlParams - optional additional url parameters
      serverHeaders - optional map whose keys indicate response headers to retrieve
      progressCallback - optional listener
      Returns:
      the server response
      Throws:
      IOException - on error
    • queryBinary

      byte[] queryBinary(String url, Map<String,String> parameters, Map<String,String> serverHeaders) throws IOException
      Perform an http GET request.
      Parameters:
      url - url with optional parameters
      parameters - optional additional url parameters
      serverHeaders - optional map whose keys indicate response headers to retrieve
      Returns:
      the server response
      Throws:
      IOException - on error
    • queryBinary

      byte[] queryBinary(String url, Map<String,String> parameters) throws IOException
      Perform an http GET request.
      Parameters:
      url - url with optional parameters
      parameters - optional additional url parameters
      Returns:
      the server response
      Throws:
      IOException - on error
    • queryBinary

      byte[] queryBinary(String url) throws IOException
      Perform an http GET request.
      Parameters:
      url - url with optional parameters
      Returns:
      the server response
      Throws:
      IOException - on error
    • downloadBinary

      long downloadBinary(File dstfile, String url, Map<String,String> urlParams, Map<String,String> serverHeaders, IProgressCallback progressCallback) throws IOException
      Download a binary and dump it to disk. Similar to queryBinary(String, Map, Map, IProgressCallback), but the downloaded data is not stored and returned, therefore making this method more suitable to download Large files.
      Parameters:
      dstfile - destination file
      url - url with optional parameters
      urlParams - optional additional url parameters
      serverHeaders - optional map whose keys indicate response headers to retrieve
      progressCallback - optional listener
      Returns:
      the number of bytes written
      Throws:
      IOException - on error
    • post

      String post(String url, Map<String,String> urlParams, Map<String,String> bodyParams, Map<String,String> serverHeaders) throws IOException
      Perform an http POST request to send a simple form.
      Parameters:
      url - url with optional parameters
      urlParams - optional additional url parameters
      bodyParams - request content parameters
      serverHeaders - optional map whose keys indicate response headers to retrieve
      Returns:
      the server response
      Throws:
      IOException - on error
    • post

      String post(String url, Map<String,String> urlParams, Map<String,String> bodyParams) throws IOException
      Perform an http POST request to send a simple form.
      Parameters:
      url - url with optional parameters
      urlParams - optional additional url parameters
      bodyParams - request content parameters
      Returns:
      the server response
      Throws:
      IOException - on error
    • postMultipart

      String postMultipart(String url, Map<String,String> formParams, Map<String,FormFileEntry> formFiles, Map<String,String> serverHeaders) throws IOException
      Perform an http POST request to send a form using the multipart/form-data encoding.
      Parameters:
      url - url with optional parameters
      formParams - optional request content parameters
      formFiles - optional request content files
      serverHeaders - optional map whose keys indicate response headers to retrieve
      Returns:
      the server response
      Throws:
      IOException - on error
    • postMultipart

      String postMultipart(String url, Map<String,String> formParams, Map<String,FormFileEntry> formFiles) throws IOException
      Perform an http POST request to send a multipart form.
      Parameters:
      url - url with optional parameters
      formParams - optional request content parameters
      formFiles - optional request content files
      Returns:
      the server response
      Throws:
      IOException - on error