Package land.oras.utils
Class OrasHttpClient
java.lang.Object
land.oras.utils.OrasHttpClient
HTTP client for ORAS
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder for the HTTP clientstatic final record
Response wrapper -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Create a new HTTP clientPerform a DELETE requestDownload to to input streamDownload to a filePerform a GET requestPerform a HEAD requestPerform a Patch requestPerform a POST request.Perform a PUT requestvoid
updateAuthentication
(AuthProvider authProvider) Update the authentication method for this client Typically used to change from basic to bearer token authentication or no auth to basic authUpload a fileuploadStream
(String method, URI uri, InputStream input, long size, Map<String, String> headers) Upload a stream
-
Method Details
-
updateAuthentication
Update the authentication method for this client Typically used to change from basic to bearer token authentication or no auth to basic auth- Parameters:
authProvider
- The auth provider
-
build
Create a new HTTP client- Returns:
- The client
-
get
Perform a GET request- Parameters:
uri
- The URIheaders
- The headers- Returns:
- The response
-
download
public OrasHttpClient.ResponseWrapper<Path> download(URI uri, Map<String, String> headers, Path file) Download to a file- Parameters:
uri
- The URIheaders
- The headersfile
- The file- Returns:
- The response
-
download
Download to to input stream- Parameters:
uri
- The URIheaders
- The headers- Returns:
- The response
-
upload
public OrasHttpClient.ResponseWrapper<String> upload(String method, URI uri, Map<String, String> headers, Path file) Upload a file- Parameters:
method
- The method (POST or PUT)uri
- The URIheaders
- The headersfile
- The file- Returns:
- The response
-
head
Perform a HEAD request- Parameters:
uri
- The URIheaders
- The headers- Returns:
- The response
-
delete
Perform a DELETE request- Parameters:
uri
- The URIheaders
- The headers- Returns:
- The response
-
post
public OrasHttpClient.ResponseWrapper<String> post(URI uri, byte[] body, Map<String, String> headers) Perform a POST request. Might not be suitable for large files. Use upload for large files.- Parameters:
uri
- The URI.body
- The bodyheaders
- The headers- Returns:
- The response
-
patch
public OrasHttpClient.ResponseWrapper<String> patch(URI uri, byte[] body, Map<String, String> headers) Perform a Patch request- Parameters:
uri
- The URIbody
- The bodyheaders
- The headers- Returns:
- The response
-
put
Perform a PUT request- Parameters:
uri
- The URIbody
- The bodyheaders
- The headers- Returns:
- The response
-
uploadStream
public OrasHttpClient.ResponseWrapper<String> uploadStream(String method, URI uri, InputStream input, long size, Map<String, String> headers) Upload a stream- Parameters:
method
- The method (POST or PUT)uri
- The URIinput
- The input streamsize
- The size of the streamheaders
- The headers- Returns:
- The response
-