Class OkHttpClientHelperKt
-
- All Implemented Interfaces:
public final class OkHttpClientHelperKt
-
-
Field Summary
Fields Modifier and Type Field Description private final static OkHttpClientokHttpClient
-
Method Summary
Modifier and Type Method Description final OkHttpClientgetOkHttpClient()The default OkHttpClient for ORT to use. final static OkHttpClient.BuilderaddBasicAuthorization(OkHttpClient.Builder $self, String username, String password)Add a request interceptor that injects basic authorization using the username and password into the client builder. final static Result<File>downloadFile(OkHttpClient $self, String url, File directory)Download from url and return a Result with a file inside directory that holds the response body content on success, or a Result wrapping an IOException (which might be a HttpDownloadError) on failure. final static Result<String>downloadText(OkHttpClient $self, String url)Download from url and return a Result with a string representing the response body content on success, or a Result wrapping an IOException (which might be a HttpDownloadError) on failure. final static Result<Pair<Response, ResponseBody>>download(OkHttpClient $self, String url, String acceptEncoding)Download from url with optional acceptEncoding and return a Result with the Response and non-nullable ResponseBody on success, or a Result wrapping an IOException (which might be a HttpDownloadError) on failure. final static Responseping(OkHttpClient $self, String url)Execute a HEAD-request against url to ping for its existence. final static Responseexecute(OkHttpClient $self, Request request)Execute a request using the client. final static Responseawait(OkHttpClient $self, Request request)Asynchronously enqueue a request using the client and await its response. final static Responseawait(Call $self)Asynchronously enqueue the Call's request and await its Response. -
-
Method Detail
-
getOkHttpClient
final OkHttpClient getOkHttpClient()
The default OkHttpClient for ORT to use.
-
addBasicAuthorization
final static OkHttpClient.Builder addBasicAuthorization(OkHttpClient.Builder $self, String username, String password)
Add a request interceptor that injects basic authorization using the username and password into the client builder.
-
downloadFile
final static Result<File> downloadFile(OkHttpClient $self, String url, File directory)
Download from url and return a Result with a file inside directory that holds the response body content on success, or a Result wrapping an IOException (which might be a HttpDownloadError) on failure.
-
downloadText
final static Result<String> downloadText(OkHttpClient $self, String url)
Download from url and return a Result with a string representing the response body content on success, or a Result wrapping an IOException (which might be a HttpDownloadError) on failure.
-
download
final static Result<Pair<Response, ResponseBody>> download(OkHttpClient $self, String url, String acceptEncoding)
Download from url with optional acceptEncoding and return a Result with the Response and non-nullable ResponseBody on success, or a Result wrapping an IOException (which might be a HttpDownloadError) on failure.
-
ping
final static Response ping(OkHttpClient $self, String url)
Execute a HEAD-request against url to ping for its existence.
-
execute
final static Response execute(OkHttpClient $self, Request request)
Execute a request using the client.
-
await
final static Response await(OkHttpClient $self, Request request)
Asynchronously enqueue a request using the client and await its response.
-
await
final static Response await(Call $self)
Asynchronously enqueue the Call's request and await its Response.
-
-
-
-