- java.lang.Object
-
- aeonics.util.Http
-
public class Http extends java.lang.Object
Simple http request fetcher. The result is returned as data. If the response mime type wasapplication/json
, then it is automatically decoded.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Http.Error
Represents an HTTP Error code with possibly a body response.
-
Field Summary
Fields Modifier and Type Field Description static int
CONNECT_TIMEOUT
The maximum number of milliseconds to wait before the connection is established.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Data
get(java.lang.String url)
Fetches the specified resource using GETstatic Data
get(java.lang.String url, Data queryString)
Fetches the specified resource using GETstatic Data
get(java.lang.String url, Data queryString, Data headers)
Fetches the specified resource using GETstatic Data
get(java.lang.String url, Data queryString, Data headers, java.lang.String method)
Fetches the specified resource using the provided method and include the parameters in the query string of the requeststatic Data
get(java.lang.String url, Data queryString, Data headers, java.lang.String method, int timeout)
Fetches the specified resource using the provided method and include the parameters in the query string of the requeststatic Data
post(java.lang.String url)
Fetches the specified resource using POSTstatic Data
post(java.lang.String url, Data body)
Fetches the specified resource using POSTstatic Data
post(java.lang.String url, Data body, Data headers)
Fetches the specified resource using POSTstatic Data
post(java.lang.String url, Data body, Data headers, java.lang.String method)
Fetches the specified resource using the provided method and include the parameters in the body of the requeststatic Data
post(java.lang.String url, Data body, Data headers, java.lang.String method, int timeout)
Fetches the specified resource using the provided method and include the parameters in the body of the request
-
-
-
Method Detail
-
post
public static Data post(java.lang.String url)
Fetches the specified resource using POST- Parameters:
url
- the url- Returns:
- the response
- Throws:
Http.Error
- if the remote endpoint returns an error (http code 400+)
-
post
public static Data post(java.lang.String url, Data body)
Fetches the specified resource using POST- Parameters:
url
- the urlbody
- the content to send in key/value pairs- Returns:
- the response
- Throws:
Http.Error
- if the remote endpoint returns an error (http code 400+)
-
post
public static Data post(java.lang.String url, Data body, Data headers)
Fetches the specified resource using POST- Parameters:
url
- the urlbody
- the content to send in key/value pairsheaders
- the http request headers- Returns:
- the response
- Throws:
Http.Error
- if the remote endpoint returns an error (http code 400+)
-
post
public static Data post(java.lang.String url, Data body, Data headers, java.lang.String method)
Fetches the specified resource using the provided method and include the parameters in the body of the request- Parameters:
url
- the urlbody
- the content to send in key/value pairsheaders
- the http request headersmethod
- the http method- Returns:
- the response
- Throws:
Http.Error
- if the remote endpoint returns an error (http code 400+)
-
post
public static Data post(java.lang.String url, Data body, Data headers, java.lang.String method, int timeout)
Fetches the specified resource using the provided method and include the parameters in the body of the request- Parameters:
url
- the urlbody
- the content to send in key/value pairsheaders
- the http request headersmethod
- the http methodtimeout
- the request timeout in milliseconds. 0 means infinite.- Returns:
- the response
- Throws:
Http.Error
- if the remote endpoint returns an error (http code 400+)
-
get
public static Data get(java.lang.String url)
Fetches the specified resource using GET- Parameters:
url
- the url- Returns:
- the response
- Throws:
Http.Error
- if the remote endpoint returns an error (http code 400+)
-
get
public static Data get(java.lang.String url, Data queryString)
Fetches the specified resource using GET- Parameters:
url
- the urlqueryString
- the content to append to the url in key/value pairs- Returns:
- the response
- Throws:
Http.Error
- if the remote endpoint returns an error (http code 400+)
-
get
public static Data get(java.lang.String url, Data queryString, Data headers)
Fetches the specified resource using GET- Parameters:
url
- the urlqueryString
- the content to append to the url in key/value pairsheaders
- the http request headers- Returns:
- the response
- Throws:
Http.Error
- if the remote endpoint returns an error (http code 400+)
-
get
public static Data get(java.lang.String url, Data queryString, Data headers, java.lang.String method)
Fetches the specified resource using the provided method and include the parameters in the query string of the request- Parameters:
url
- the urlqueryString
- the content to append to the url in key/value pairsheaders
- the http request headersmethod
- the http method- Returns:
- the response
- Throws:
Http.Error
- if the remote endpoint returns an error (http code 400+)
-
get
public static Data get(java.lang.String url, Data queryString, Data headers, java.lang.String method, int timeout)
Fetches the specified resource using the provided method and include the parameters in the query string of the request- Parameters:
url
- the urlqueryString
- the content to append to the url in key/value pairsheaders
- the http request headersmethod
- the http methodtimeout
- the request timeout in milliseconds. 0 means infinite.- Returns:
- the response
- Throws:
Http.Error
- if the remote endpoint returns an error (http code 400+)
-
-