Package VASSAL.tools

Class HTTPPostBuilder

java.lang.Object
VASSAL.tools.HTTPPostBuilder

public class HTTPPostBuilder
extends Object
Builds HTTP POST requests conveniently.
Since:
3.1.0
Author:
Joel Uckelman
  • Constructor Details

    • HTTPPostBuilder

      public HTTPPostBuilder()
  • Method Details

    • setParameter

      public void setParameter​(String name, String value) throws IOException
      Sets a parameter for an HTTP POST request.
      Parameters:
      name - the name of the parameter
      value - the value of the parameter
      Throws:
      IOException - in case of failure
    • setParameter

      public void setParameter​(String name, File file) throws IOException
      Sets a file to be uploaded as part of an HTTP POST request.
      Parameters:
      name - the name of the parameter
      file - the path to the file
      Throws:
      IOException - in case of failure
    • setParameter

      public void setParameter​(String name, String filename, InputStream in) throws IOException
      Sets a file to be uploaded as part of an HTTP POST request.
      Parameters:
      name - the name of the parameter
      filename - the path to the file
      in - an InputStream from which to read the file
      Throws:
      IOException - in case of failure
    • setParameter

      public void setParameter​(String name, String filename, String contents) throws IOException
      Sets a file to be uploaded as part of an HTTP POST request.
      Parameters:
      name - the name of the parameter
      filename - the path to the file
      contents - a String containing the file
      Throws:
      IOException - in case of failure
    • post

      public InputStream post​(String url) throws IOException
      Submits an HTTP POST request to the given URL. This convenience method is equivalent to HTTPPostBuilder.post(new URL(url)).
      Parameters:
      url - the URL to receive the POST request
      Returns:
      the reply
      Throws:
      IOException - in case of failure
    • post

      public InputStream post​(URL url) throws IOException
      Submits an HTTP POST request to the given URL.
      Parameters:
      url - the URL to receive the POST request
      Returns:
      the reply
      Throws:
      IOException - in case of failure