public class HttpUtil extends Object
| Constructor and Description |
|---|
HttpUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
appendQueryParams(String url,
Map<String,String> params)
Append query parameters to given url
|
static String |
delete(String url)
Send a delete request
|
static String |
delete(String url,
Map<String,String> headers)
Send a delete request
|
static String |
fetch(String method,
String url,
String body,
Map<String,String> headers)
Send a request
|
static String |
get(String url)
Send a get request
|
static String |
get(String url,
Map<String,String> headers)
Send a get request
|
static Map<String,String> |
getQueryParams(String url)
Retrieve the query parameters from given url
|
static String |
post(String url,
String body)
Send a post request
|
static String |
post(String url,
String body,
Map<String,String> headers)
Send a post request
|
static String |
postForm(String url,
Map<String,String> params)
Post a form with parameters
|
static String |
postForm(String url,
Map<String,String> params,
Map<String,String> headers)
Post a form with parameters
|
static String |
put(String url,
String body)
Send a put request
|
static String |
put(String url,
String body,
Map<String,String> headers)
Send a put request
|
static String |
removeQueryParams(String url)
Returns the url without query parameters
|
static String |
streamToString(InputStream in)
Read an input stream into a string
|
public static String get(String url) throws IOException
url - URL on which an HTTP GET request is performedIOException - Errors in connecting to the given URLpublic static String get(String url, Map<String,String> headers) throws IOException
url - Url as stringheaders - Optional map with headersIOException - Errors in connecting to the given URLpublic static String post(String url, String body, Map<String,String> headers) throws IOException
url - Url as stringbody - Request body as stringheaders - Optional map with headersIOException - Errors in connecting to the given URLpublic static String post(String url, String body) throws IOException
url - Url as stringbody - Request body as stringIOException - Errors in connecting to the given URLpublic static String postForm(String url, Map<String,String> params) throws IOException
url - Url as stringparams - map with parameters/valuesIOException - Errors in connecting to the given URLpublic static String postForm(String url, Map<String,String> params, Map<String,String> headers) throws IOException
url - Url as stringparams - Map with parameters/valuesheaders - Optional map with headersIOException - Errors in connecting to the given URLpublic static String put(String url, String body, Map<String,String> headers) throws IOException
url - Url as stringbody - Request body as stringheaders - Optional map with headersIOException - Errors in connecting to the given URLpublic static String put(String url, String body) throws IOException
url - Url as stringbody - The payload that is added to this PUT requestIOException - Errors in connecting to the given URLpublic static String delete(String url, Map<String,String> headers) throws IOException
url - Url as stringheaders - Optional map with headersIOException - Errors in connecting to the given URLpublic static String delete(String url) throws IOException
url - Url as stringIOException - Errors in connecting to the given URLpublic static String appendQueryParams(String url, Map<String,String> params) throws IOException
url - Url as stringparams - Map with query parametersIOException - Errors in connecting to the given URLpublic static Map<String,String> getQueryParams(String url) throws IOException
url - Url containing query parametersIOException - Errors in connecting to the given URLpublic static String removeQueryParams(String url) throws IOException
url - Url containing query parametersIOException - Errors in connecting to the given URLpublic static String fetch(String method, String url, String body, Map<String,String> headers) throws IOException
method - HTTP method, for example "GET" or "POST"url - Url as stringbody - Request body as stringheaders - Optional map with headersIOException - Errors in connecting to the given URLpublic static String streamToString(InputStream in) throws IOException
in - Inputstream that is captured from a responseIOException - Errors in connecting to the given URLCopyright © 2017 AskFast BV. All Rights Reserved.