Class WebUtils

java.lang.Object
org.geysermc.geyser.util.WebUtils

public class WebUtils extends Object
  • Constructor Details

    • WebUtils

      public WebUtils()
  • Method Details

    • getBody

      public static String getBody(String reqURL)
      Makes a web request to the given URL and returns the body as a string
      Parameters:
      reqURL - URL to fetch
      Returns:
      Body contents or error message if the request fails
    • getJson

      public static com.fasterxml.jackson.databind.JsonNode getJson(String reqURL) throws IOException
      Makes a web request to the given URL and returns the body as a JsonNode.
      Parameters:
      reqURL - URL to fetch
      Returns:
      the response as JSON
      Throws:
      IOException
    • downloadFile

      public static void downloadFile(String reqURL, String fileLocation)
      Downloads a file from the given URL and saves it to disk
      Parameters:
      reqURL - File to fetch
      fileLocation - Location to save on disk
    • post

      public static String post(String reqURL, String postContent) throws IOException
      Post a string to the given URL
      Parameters:
      reqURL - URL to post to
      postContent - String data to post
      Returns:
      String returned by the server
      Throws:
      IOException
    • postForm

      public static String postForm(String reqURL, Map<String,​String> fields) throws IOException
      Post fields to a URL as a form
      Parameters:
      reqURL - URL to post to
      fields - Form data to post
      Returns:
      String returned by the server
      Throws:
      IOException