Package land.oras.auth
Class HttpClient
java.lang.Object
land.oras.auth.HttpClient
HTTP client for ORAS
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for the HTTP clientstatic final recordResponse wrapperstatic final recordThe token response -
Method Summary
Modifier and TypeMethodDescriptionbuild()Create a new HTTP clientPerform a DELETE requestDownload to a fileDownload to to input streamPerform a GET requestPerform a HEAD requestPerform a Patch requestPerform a POST request.Perform a PUT requestrefreshToken(HttpClient.ResponseWrapper<T> response, Scopes scopes, AuthProvider authProvider) Retrieve a token from the registryupload(String method, URI uri, Map<String, String> headers, Path file, Scopes scopes, AuthProvider authProvider) Upload a file
-
Method Details
-
build
Create a new HTTP client- Returns:
- The client
-
get
public HttpClient.ResponseWrapper<String> get(URI uri, Map<String, String> headers, Scopes scopes, AuthProvider authProvider) Perform a GET request- Parameters:
uri- The URIheaders- The headersscopes- The scopesauthProvider- The authentication provider- Returns:
- The response
-
download
public HttpClient.ResponseWrapper<Path> download(URI uri, Map<String, String> headers, Path file, Scopes scopes, AuthProvider authProvider) Download to a file- Parameters:
uri- The URIheaders- The headersfile- The filescopes- The scopesauthProvider- The authentication provider- Returns:
- The response
-
download
public HttpClient.ResponseWrapper<InputStream> download(URI uri, Map<String, String> headers, Scopes scopes, AuthProvider authProvider) Download to to input stream- Parameters:
uri- The URIheaders- The headersscopes- The scopesauthProvider- The authentication provider- Returns:
- The response
-
upload
public HttpClient.ResponseWrapper<String> upload(String method, URI uri, Map<String, String> headers, Path file, Scopes scopes, AuthProvider authProvider) Upload a file- Parameters:
method- The method (POST or PUT)uri- The URIheaders- The headersfile- The filescopes- The scopesauthProvider- The authentication provider- Returns:
- The response
-
head
public HttpClient.ResponseWrapper<String> head(URI uri, Map<String, String> headers, Scopes scopes, AuthProvider authProvider) Perform a HEAD request- Parameters:
uri- The URIheaders- The headersscopes- The scopesauthProvider- The authentication provider- Returns:
- The response
-
delete
public HttpClient.ResponseWrapper<String> delete(URI uri, Map<String, String> headers, Scopes scopes, AuthProvider authProvider) Perform a DELETE request- Parameters:
uri- The URIheaders- The headersscopes- The scopesauthProvider- The authentication provider- Returns:
- The response
-
post
public HttpClient.ResponseWrapper<String> post(URI uri, byte[] body, Map<String, String> headers, Scopes scopes, AuthProvider authProvider) Perform a POST request. Might not be suitable for large files. Use upload for large files.- Parameters:
uri- The URI.body- The bodyheaders- The headersscopes- The scopesauthProvider- The authentication provider- Returns:
- The response
-
patch
public HttpClient.ResponseWrapper<String> patch(URI uri, byte[] body, Map<String, String> headers, Scopes scopes, AuthProvider authProvider) Perform a Patch request- Parameters:
uri- The URIbody- The bodyheaders- The headersscopes- The scopesauthProvider- The authentication provider- Returns:
- The response
-
put
public HttpClient.ResponseWrapper<String> put(URI uri, byte[] body, Map<String, String> headers, Scopes scopes, AuthProvider authProvider) Perform a PUT request- Parameters:
uri- The URIbody- The bodyheaders- The headersscopes- The scopesauthProvider- The authentication provider- Returns:
- The response
-
refreshToken
public <T> HttpClient.TokenResponse refreshToken(HttpClient.ResponseWrapper<T> response, Scopes scopes, AuthProvider authProvider) Retrieve a token from the registry- Type Parameters:
T- The response type- Parameters:
response- The response that may contain a the WWW-Authenticate headerscopes- The scopesauthProvider- The authentication provider- Returns:
- The token
-