Package kong.unirest

Class Unirest


  • public class Unirest
    extends Object
    • Constructor Detail

      • Unirest

        public Unirest()
    • Method Detail

      • config

        public static Config config()
        Access the default configuration for the primary Unirest instance.
        Returns:
        the config object of the primary instance
      • shutDown

        public static void shutDown()
        Close the asynchronous client and its event loop. Use this method to close all the threads and allow an application to exit. This will also clear any options returning Unirest to a default state
      • shutDown

        public static void shutDown​(boolean clearOptions)
        Close the asynchronous client and its event loop. Use this method to close all the threads and allow an application to exit.
        Parameters:
        clearOptions - indicates if options should be cleared. Note that the HttpClient, AsyncClient and thread monitors will not be retained after shutDown.
      • get

        public static GetRequest get​(String url)
        Start a GET HttpRequest which does not support a body from the primary config
        Parameters:
        url - the endpoint to access. Can include placeholders for path params using curly braces {}
        Returns:
        A HttpRequest builder
      • head

        public static GetRequest head​(String url)
        Start a HEAD HttpRequest which does not support a body from the primary config
        Parameters:
        url - the endpoint to access. Can include placeholders for path params using curly braces {}
        Returns:
        A HttpRequest builder
      • options

        public static GetRequest options​(String url)
        Start a OPTIONS HttpRequest which does not support a body from the primary config
        Parameters:
        url - the endpoint to access. Can include placeholders for path params using curly braces {}
        Returns:
        A HttpRequest builder
      • post

        public static HttpRequestWithBody post​(String url)
        Start a POST HttpRequest which supports a body from the primary config
        Parameters:
        url - the endpoint to access. Can include placeholders for path params using curly braces {}
        Returns:
        A HttpRequest builder
      • delete

        public static HttpRequestWithBody delete​(String url)
        Start a DELETE HttpRequest which supports a body from the primary config
        Parameters:
        url - the endpoint to access. Can include placeholders for path params using curly braces {}
        Returns:
        A HttpRequest builder
      • patch

        public static HttpRequestWithBody patch​(String url)
        Start a PATCH HttpRequest which supports a body from the primary config
        Parameters:
        url - the endpoint to access. Can include placeholders for path params using curly braces {}
        Returns:
        A HttpRequest builder
      • put

        public static HttpRequestWithBody put​(String url)
        Start a PUT HttpRequest which supports a body from the primary config
        Parameters:
        url - the endpoint to access. Can include placeholders for path params using curly braces {}
        Returns:
        A HttpRequest builder
      • jsonPatch

        public static JsonPatchRequest jsonPatch​(String url)
        Start a PATCH HttpRequest which supports a JSON Patch builder. this supports RFC-6902 https://tools.ietf.org/html/rfc6902
        Parameters:
        url - the endpoint to access. Can include placeholders for path params using curly braces {}
        Returns:
        A HttpRequest builder
      • spawnInstance

        public static UnirestInstance spawnInstance()
        Spawn a new Unirest Instance with a new config. Don't forget to shut it down when your done. It will not be tracked and shutdown with Unirest.shutDown()
        Returns:
        a new UnirestInstance
      • primaryInstance

        public static UnirestInstance primaryInstance()
        return the primary UnirestInstance.
        Returns:
        a new UnirestInstance