Class Curl

java.lang.Object
org.codelibs.curl.Curl

public class Curl extends Object
The Curl class provides a simple interface for creating HTTP requests using various HTTP methods. It includes static methods for each HTTP method that return a CurlRequest object.

Example usage:

 CurlRequest request = Curl.get("http://example.com");
 

Supported HTTP methods:

  • GET
  • POST
  • PUT
  • DELETE
  • HEAD
  • OPTIONS
  • CONNECT

The Curl class also defines an enum Curl.Method which lists all supported HTTP methods.

The temporary directory used by Curl is defined by the tmpDir field, which is initialized to the system's temporary directory.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enumeration representing HTTP methods.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final File
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new CurlRequest with the CONNECT method for the specified URL.
    Creates a new CurlRequest with the DELETE method for the specified URL.
    get(String url)
    Creates a new CurlRequest with the HTTP GET method for the specified URL.
    head(String url)
    Creates a new CurlRequest with the HTTP HEAD method for the specified URL.
    Creates a new CurlRequest with the HTTP OPTIONS method for the specified URL.
    post(String url)
    Creates a new CurlRequest with the HTTP POST method for the specified URL.
    put(String url)
    Creates a new CurlRequest with the HTTP PUT method for the specified URL.

    Methods inherited from class java.lang.Object

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

    • tmpDir

      public static final File tmpDir
  • Constructor Details

    • Curl

      protected Curl()
  • Method Details

    • get

      public static CurlRequest get(String url)
      Creates a new CurlRequest with the HTTP GET method for the specified URL.
      Parameters:
      url - the URL to send the GET request to
      Returns:
      a CurlRequest object configured with the GET method and the specified URL
    • post

      public static CurlRequest post(String url)
      Creates a new CurlRequest with the HTTP POST method for the specified URL.
      Parameters:
      url - the URL to which the POST request will be sent
      Returns:
      a new CurlRequest object configured with the POST method and the specified URL
    • put

      public static CurlRequest put(String url)
      Creates a new CurlRequest with the HTTP PUT method for the specified URL.
      Parameters:
      url - the URL to which the PUT request will be sent
      Returns:
      a new CurlRequest object configured with the PUT method and the specified URL
    • delete

      public static CurlRequest delete(String url)
      Creates a new CurlRequest with the DELETE method for the specified URL.
      Parameters:
      url - the URL to which the DELETE request will be sent
      Returns:
      a CurlRequest object configured with the DELETE method and the specified URL
    • head

      public static CurlRequest head(String url)
      Creates a new CurlRequest with the HTTP HEAD method for the specified URL.
      Parameters:
      url - the URL to which the HEAD request is to be made
      Returns:
      a CurlRequest object configured with the HEAD method and the specified URL
    • options

      public static CurlRequest options(String url)
      Creates a new CurlRequest with the HTTP OPTIONS method for the specified URL.
      Parameters:
      url - the URL to which the OPTIONS request is sent
      Returns:
      a new CurlRequest object configured with the OPTIONS method and the specified URL
    • connect

      public static CurlRequest connect(String url)
      Creates a new CurlRequest with the CONNECT method for the specified URL.
      Parameters:
      url - the URL to connect to
      Returns:
      a new CurlRequest object with the CONNECT method