Class Unirest


  • public class Unirest
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Unirest()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Config config()
      Access the default configuration for the primary Unirest instance.
      static HttpRequestWithBody delete​(java.lang.String url)
      Start a DELETE HttpRequest which supports a body from the primary config
      static GetRequest get​(java.lang.String url)
      Start a GET HttpRequest which does not support a body from the primary config
      static GetRequest head​(java.lang.String url)
      Start a HEAD HttpRequest which does not support a body from the primary config
      static JsonPatchRequest jsonPatch​(java.lang.String url)
      Start a PATCH HttpRequest which supports a JSON Patch builder.
      static GetRequest options​(java.lang.String url)
      Start a OPTIONS HttpRequest which does not support a body from the primary config
      static HttpRequestWithBody patch​(java.lang.String url)
      Start a PATCH HttpRequest which supports a body from the primary config
      static HttpRequestWithBody post​(java.lang.String url)
      Start a POST HttpRequest which supports a body from the primary config
      static UnirestInstance primaryInstance()
      return the primary UnirestInstance.
      static HttpRequestWithBody put​(java.lang.String url)
      Start a PUT HttpRequest which supports a body from the primary config
      static HttpRequestWithBody request​(java.lang.String method, java.lang.String url)  
      static void shutDown()
      Close the asynchronous client and its event loop.
      static void shutDown​(boolean clearOptions)
      Close the asynchronous client and its event loop.
      static UnirestInstance spawnInstance()
      Spawn a new Unirest Instance with a new config.
      static WebSocketRequest webSocket​(java.lang.String url)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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
      • request

        public static HttpRequestWithBody request​(java.lang.String method,
                                                  java.lang.String url)
      • webSocket

        public static WebSocketRequest webSocket​(java.lang.String url)
      • 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