Class Http
-
- All Implemented Interfaces:
public class HttpHttp Utilities
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classHttp.HttpExceptionpublic classHttp.QueryBuilderQueryString Builder
public classHttp.MultiPartBuilderUtility to build MultiPart requests
public classHttp.RequestRequest Builder
public classHttp.ResponseResponse obtained by calling Request.execute()
-
Constructor Summary
Constructors Constructor Description Http()
-
Method Summary
Modifier and Type Method Description static StringsimpleGet(String url)Send a simple GET request static voidsimpleDownload(String url, File outputFile)Download content from the specified url to the specified File static <T> TsimpleJsonGet(String url, Type schema)Send a simple GET request static <T> TsimpleJsonGet(String url, Class<T> schema)Send a simple GET request static StringsimplePost(String url, String body)Send a simple POST request static <T> TsimpleJsonPost(String url, String body, Type schema)Send a simple POST request and parse the JSON response static <T> TsimpleJsonPost(String url, String body, Class<T> schema)Send a simple POST request and parse the JSON response static <T> TsimpleJsonPost(String url, Object body, Type schema)Send a simple POST request with JSON body static <T> TsimpleJsonPost(String url, Object body, Class<T> schema)Send a simple POST request with JSON body -
-
Method Detail
-
simpleGet
static String simpleGet(String url)
Send a simple GET request
- Parameters:
url- The url to fetch- Returns:
Raw response (String). If you want Json, use simpleJsonGet
-
simpleDownload
static void simpleDownload(String url, File outputFile)
Download content from the specified url to the specified File
- Parameters:
url- The url to download content fromoutputFile- The file to save to
-
simpleJsonGet
static <T> T simpleJsonGet(String url, Type schema)
Send a simple GET request
- Parameters:
url- The url to fetchschema- Class to deserialize the response into- Returns:
Response Object
-
simpleJsonGet
static <T> T simpleJsonGet(String url, Class<T> schema)
Send a simple GET request
- Parameters:
url- The url to fetchschema- Class to deserialize the response into- Returns:
Response Object
-
simplePost
static String simplePost(String url, String body)
Send a simple POST request
- Parameters:
url- The url to fetchbody- The request body- Returns:
Raw response (String). If you want Json, use simpleJsonPost
-
simpleJsonPost
static <T> T simpleJsonPost(String url, String body, Type schema)
Send a simple POST request and parse the JSON response
- Parameters:
url- The url to fetchbody- The request bodyschema- Class to deserialize the response into- Returns:
Response deserialized into the provided Class
-
simpleJsonPost
static <T> T simpleJsonPost(String url, String body, Class<T> schema)
Send a simple POST request and parse the JSON response
- Parameters:
url- The url to fetchbody- The request bodyschema- Class to deserialize the response into- Returns:
Response deserialized into the provided Class
-
simpleJsonPost
static <T> T simpleJsonPost(String url, Object body, Type schema)
Send a simple POST request with JSON body
- Parameters:
url- The url to fetchbody- The request bodyschema- Class to deserialize the response into- Returns:
Response deserialized into the provided Class
-
simpleJsonPost
static <T> T simpleJsonPost(String url, Object body, Class<T> schema)
Send a simple POST request with JSON body
- Parameters:
url- The url to fetchbody- The request bodyschema- Class to deserialize the response into- Returns:
Response deserialized into the provided Class
-
-
-
-