Class HttpRequest

java.lang.Object
com.sk89q.worldedit.util.net.HttpRequest
All Implemented Interfaces:
Closeable, AutoCloseable

@Deprecated(forRemoval=true) public class HttpRequest extends Object implements Closeable
Deprecated, for removal: This API element is subject to removal in a future version.
Use the native JDK HttpClient API instead.
A class for making HTTP requests.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    Deprecated, for removal: This API element is subject to removal in a future version.
    Used to buffer the response in memory.
    static final class 
    Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Summary

    Modifier and Type
    Method
    Description
    body(String data)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Submit data.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Submit form data.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Submit form data.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
    Execute the request.
    expectResponseCode(int... codes)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Require that the response code is one of the given response codes.
    get(URL url)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Perform a GET request.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the input stream.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the response code.
    header(String key, String value)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Add a header.
    post(URL url)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Perform a POST request.
    request(String method, URL url)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Perform a request.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Buffer the returned response.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Save the result to a file.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Save the result to an output stream.
    static URL
    url(String url)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a new URL and throw a RuntimeException if the URL is not valid.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • body

      public HttpRequest body(String data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Submit data.
      Returns:
      this object
    • bodyUrlEncodedForm

      public HttpRequest bodyUrlEncodedForm(HttpRequest.Form form)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Submit form data.
      Parameters:
      form - the form
      Returns:
      this object
    • bodyMultipartForm

      public HttpRequest bodyMultipartForm(HttpRequest.Form form)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Submit form data.
      Parameters:
      form - the form
      Returns:
      this object
    • header

      public HttpRequest header(String key, String value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Add a header.
      Parameters:
      key - the header key
      value - the header value
      Returns:
      this object
    • execute

      public HttpRequest execute() throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Execute the request.

      After execution, close() should be called.

      Returns:
      this object
      Throws:
      IOException - on I/O error
    • expectResponseCode

      public HttpRequest expectResponseCode(int... codes) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Require that the response code is one of the given response codes.
      Parameters:
      codes - a list of codes
      Returns:
      this object
      Throws:
      IOException - if there is an I/O error or the response code is not expected
    • getResponseCode

      public int getResponseCode() throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the response code.
      Returns:
      the response code
      Throws:
      IOException - on I/O error
    • getInputStream

      public InputStream getInputStream()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the input stream.
      Returns:
      the input stream
    • returnContent

      Deprecated, for removal: This API element is subject to removal in a future version.
      Buffer the returned response.
      Returns:
      the buffered response
      Throws:
      IOException - on I/O error
      InterruptedException - on interruption
    • saveContent

      public HttpRequest saveContent(File file) throws IOException, InterruptedException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Save the result to a file.
      Parameters:
      file - the file
      Returns:
      this object
      Throws:
      IOException - on I/O error
      InterruptedException - on interruption
    • saveContent

      public HttpRequest saveContent(OutputStream out) throws IOException, InterruptedException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Save the result to an output stream.
      Parameters:
      out - the output stream
      Returns:
      this object
      Throws:
      IOException - on I/O error
      InterruptedException - on interruption
    • close

      public void close()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • get

      public static HttpRequest get(URL url)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Perform a GET request.
      Parameters:
      url - the URL
      Returns:
      a new request object
    • post

      public static HttpRequest post(URL url)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Perform a POST request.
      Parameters:
      url - the URL
      Returns:
      a new request object
    • request

      public static HttpRequest request(String method, URL url)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Perform a request.
      Parameters:
      method - the method
      url - the URL
      Returns:
      a new request object
    • url

      public static URL url(String url)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a new URL and throw a RuntimeException if the URL is not valid.
      Parameters:
      url - the url
      Returns:
      a URL object
      Throws:
      RuntimeException - if the URL is invalid