Package ai.devtools.utils
Class NetUtils
- java.lang.Object
-
- ai.devtools.utils.NetUtils
-
public class NetUtils extends Object
Shared network/http-related utilities and functionality
-
-
Constructor Summary
Constructors Constructor Description NetUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static okhttp3.OkHttpClient.BuilderbasicClient()Convenience method, creates a new OkHttpBuilder with timeouts configured.static okhttp3.ResponsebasicPOST(okhttp3.OkHttpClient client, okhttp3.HttpUrl baseURL, String endpoint, com.google.gson.JsonObject jo)Performs a simple POST to the specified url with the provided client and json data.static okhttp3.ResponsebasicPOST(okhttp3.OkHttpClient client, okhttp3.HttpUrl baseURL, String endpoint, HashMap<String,String> form)Performs a simple form POST to the specified url with the provided client and form data.static com.google.gson.JsonObjectpost(String url, com.google.gson.JsonObject json)static okhttp3.OkHttpClientunsafeClient()Creates a newOkHttpClientwhich ignores expired/invalid ssl certificates.
-
-
-
Method Detail
-
post
public static com.google.gson.JsonObject post(String url, com.google.gson.JsonObject json) throws IOException
- Throws:
IOException
-
basicPOST
public static okhttp3.Response basicPOST(okhttp3.OkHttpClient client, okhttp3.HttpUrl baseURL, String endpoint, com.google.gson.JsonObject jo) throws IOExceptionPerforms a simple POST to the specified url with the provided client and json data.- Parameters:
client- The OkHttp client to usebaseURL- The base URL to targetendpoint- The endpoint on the baseURL to target.jo- The JsonObject to put in the request body- Returns:
- The response from the server, in the form of a
Responseobject - Throws:
IOException- Network error
-
basicPOST
public static okhttp3.Response basicPOST(okhttp3.OkHttpClient client, okhttp3.HttpUrl baseURL, String endpoint, HashMap<String,String> form) throws IOExceptionPerforms a simple form POST to the specified url with the provided client and form data.- Parameters:
client- The OkHttp client to usebaseURL- The base URL to targetendpoint- The endpoint on the baseURL to target.form- The form data to POST- Returns:
- The response from the server, in the form of a
Responseobject - Throws:
IOException- Network error
-
basicClient
public static okhttp3.OkHttpClient.Builder basicClient()
Convenience method, creates a new OkHttpBuilder with timeouts configured.- Returns:
- A OkHttpClient builder with reasonable timeouts configured.
-
unsafeClient
public static okhttp3.OkHttpClient unsafeClient()
Creates a newOkHttpClientwhich ignores expired/invalid ssl certificates. Normally, OkHttp will raise an exception if it encounters bad certificates.- Returns:
- A new
OkHttpClientwhich ignores expired/invalid ssl certificates.
-
-