Package kong.unirest.core
Class Unirest
- java.lang.Object
-
- kong.unirest.core.Unirest
-
public class Unirest extends Object
-
-
Constructor Summary
Constructors Constructor Description Unirest()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Configconfig()Access the default configuration for the primary Unirest instance.static HttpRequestWithBodydelete(String url)Start a DELETE HttpRequest which supports a body from the primary configstatic GetRequestget(String url)Start a GET HttpRequest which does not support a body from the primary configstatic GetRequesthead(String url)Start a HEAD HttpRequest which does not support a body from the primary configstatic JsonPatchRequestjsonPatch(String url)Start a PATCH HttpRequest which supports a JSON Patch builder.static GetRequestoptions(String url)Start a OPTIONS HttpRequest which does not support a body from the primary configstatic HttpRequestWithBodypatch(String url)Start a PATCH HttpRequest which supports a body from the primary configstatic HttpRequestWithBodypost(String url)Start a POST HttpRequest which supports a body from the primary configstatic UnirestInstanceprimaryInstance()return the primary UnirestInstance.static HttpRequestWithBodyput(String url)Start a PUT HttpRequest which supports a body from the primary configstatic HttpRequestWithBodyrequest(String method, String url)static voidshutDown()Close the asynchronous client and its event loop.static voidshutDown(boolean clearOptions)Close the asynchronous client and its event loop.static UnirestInstancespawnInstance()Spawn a new Unirest Instance with a new config.static WebSocketRequestwebSocket(String url)
-
-
-
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
-
request
public static HttpRequestWithBody request(String method, String url)
-
webSocket
public static WebSocketRequest webSocket(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
-
-