Interface WebUtil


public interface WebUtil
Small helpers for the plugin's outgoing http requests.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Duration
    The timeout applied to every outgoing request.
    static final String
    The user agent sent with every outgoing request.
  • Method Summary

    Modifier and Type
    Method
    Description
    Opens a connection carrying the plugin's user agent.
    int
    downloadFile(String fileUrl, Path outputPath, boolean warn404)
    Downloads a file to disk.
  • Field Details

    • USER_AGENT

      static final String USER_AGENT
      The user agent sent with every outgoing request.
      See Also:
    • REQUEST_TIMEOUT

      static final Duration REQUEST_TIMEOUT
      The timeout applied to every outgoing request.
  • Method Details

    • downloadFile

      int downloadFile(String fileUrl, Path outputPath, boolean warn404)
      Downloads a file to disk.
      Parameters:
      fileUrl - the url
      outputPath - where to write it
      warn404 - whether a missing file is worth a log line
      Returns:
      the http status code, or -1 if the request never completed
    • createConnection

      HttpURLConnection createConnection(String url) throws IOException
      Opens a connection carrying the plugin's user agent.
      Parameters:
      url - the url
      Returns:
      the open connection
      Throws:
      IOException - if the connection cannot be opened