Package ai.devtools.utils
Class NetUtils
java.lang.Object
ai.devtools.utils.NetUtils
Shared network/http-related utilities and functionality
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic okhttp3.OkHttpClient.BuilderConvenience 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.JsonObjectstatic okhttp3.OkHttpClientCreates a newOkHttpClientwhich ignores expired/invalid ssl certificates.
-
Constructor Details
-
NetUtils
public NetUtils()
-
-
Method Details
-
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 IOException Performs 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.
-