Package com.mashape.unirest.http
Class Unirest
- java.lang.Object
-
- com.mashape.unirest.http.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 voidclearDefaultHeaders()Clear default headersstatic HttpRequestWithBodydelete(String url)static GetRequestget(String url)static GetRequesthead(String url)static HttpRequestWithBodyoptions(String url)static HttpRequestWithBodypatch(String url)static HttpRequestWithBodypost(String url)static HttpRequestWithBodyput(String url)static voidsetAsyncHttpClient(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncHttpClient)Set the asynchronous AbstractHttpAsyncClient implementation to use for every asynchronous requeststatic voidsetConcurrency(int maxTotal, int maxPerRoute)Set the concurrency levelsstatic voidsetDefaultHeader(String name, String value)Set default headerstatic voidsetHttpClient(org.apache.http.client.HttpClient httpClient)Set the HttpClient implementation to use for every synchronous requeststatic voidsetProxy(org.apache.http.HttpHost proxy)Set a proxystatic voidsetTimeouts(long connectionTimeout, long socketTimeout)Set the connection timeout and socket timeoutstatic voidshutdown()Close the asynchronous client and its event loop.
-
-
-
Method Detail
-
setHttpClient
public static void setHttpClient(org.apache.http.client.HttpClient httpClient)
Set the HttpClient implementation to use for every synchronous request
-
setAsyncHttpClient
public static void setAsyncHttpClient(org.apache.http.impl.nio.client.CloseableHttpAsyncClient asyncHttpClient)
Set the asynchronous AbstractHttpAsyncClient implementation to use for every asynchronous request
-
setProxy
public static void setProxy(org.apache.http.HttpHost proxy)
Set a proxy
-
setTimeouts
public static void setTimeouts(long connectionTimeout, long socketTimeout)Set the connection timeout and socket timeout- Parameters:
connectionTimeout- The timeout until a connection with the server is established (in milliseconds). Default is 10000. Set to zero to disable the timeout.socketTimeout- The timeout to receive data (in milliseconds). Default is 60000. Set to zero to disable the timeout.
-
setConcurrency
public static void setConcurrency(int maxTotal, int maxPerRoute)Set the concurrency levels- Parameters:
maxTotal- Defines the overall connection limit for a connection pool. Default is 200.maxPerRoute- Defines a connection limit per one HTTP route (this can be considered a per target host limit). Default is 20.
-
clearDefaultHeaders
public static void clearDefaultHeaders()
Clear default headers
-
shutdown
public static void shutdown() throws IOExceptionClose the asynchronous client and its event loop. Use this method to close all the threads and allow an application to exit.- Throws:
IOException
-
get
public static GetRequest get(String url)
-
head
public static GetRequest head(String url)
-
options
public static HttpRequestWithBody options(String url)
-
post
public static HttpRequestWithBody post(String url)
-
delete
public static HttpRequestWithBody delete(String url)
-
patch
public static HttpRequestWithBody patch(String url)
-
put
public static HttpRequestWithBody put(String url)
-
-