Package kong.unirest.core
Class UnirestInstance
java.lang.Object
kong.unirest.core.UnirestInstance
A Instance of the unirest runtime, you can have many of these but it is the config
and its clients where all the action happens.
This class is suitable for mocking.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Wraps shutdown and will automatically be called when UnirestInstance is used with try-with-resource.config()
Access the default configuration for the primary Unirest instance.Start a DELETE HttpRequest which supports a body from the primary configStart a GET HttpRequest which does not support a body from the primary configStart a HEAD HttpRequest which does not support a body from the primary configStart a PATCH HttpRequest which supports a JSON Patch builder.Start a OPTIONS HttpRequest which does not support a body from the primary configStart a PATCH HttpRequest which supports a body from the primary configStart a POST HttpRequest which supports a body from the primary configStart a PUT HttpRequest which supports a body from the primary configvoid
reset()
Close the asynchronous client and its event loop.void
reset
(boolean clearOptions) Close the asynchronous client and its event loop.
-
Field Details
-
config
-
-
Constructor Details
-
UnirestInstance
Create a new UnirestInstance with a config- Parameters:
config
- the config for the instance
-
-
Method Details
-
config
Access the default configuration for the primary Unirest instance.- Returns:
- the instance's config
-
reset
public void reset()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 -
reset
public void reset(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
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
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
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
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
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
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
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
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
-
close
public void close()Wraps shutdown and will automatically be called when UnirestInstance is used with try-with-resource. This will alleviate the need to manually call shutDown as it will be done automatically. -
webSocket
-