java.lang.Object
org.miaixz.bus.http.bodys.RequestBody
org.miaixz.bus.http.plugin.httpv.ProgressBody
A
RequestBody decorator that monitors the progress of an upload. It wraps an existing RequestBody and invokes
a callback with progress updates as data is being written to the network.- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionProgressBody(RequestBody requestBody, Callback<Progress> onProcess, Executor callbackExecutor, long contentLength, long stepBytes) Constructs a new ProgressBody. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the number of bytes that will be written tosinkwhen this request body is transmitted, or -1 if that count is unknown.org.miaixz.bus.core.lang.MediaTypeReturns the media type of this request body.voidwriteTo(org.miaixz.bus.core.io.sink.BufferSink sink) Writes the content of this request body to the given sink.
-
Constructor Details
-
ProgressBody
public ProgressBody(RequestBody requestBody, Callback<Progress> onProcess, Executor callbackExecutor, long contentLength, long stepBytes) Constructs a new ProgressBody.- Parameters:
requestBody- The actual request body to wrap.onProcess- The callback to receive progress updates.callbackExecutor- The executor to run the callback on.contentLength- The total length of the request body.stepBytes- The interval in bytes for progress updates.
-
-
Method Details
-
contentLength
public long contentLength()Description copied from class:RequestBodyReturns the number of bytes that will be written tosinkwhen this request body is transmitted, or -1 if that count is unknown.- Overrides:
contentLengthin classRequestBody- Returns:
- The content length.
-
contentType
public org.miaixz.bus.core.lang.MediaType contentType()Description copied from class:RequestBodyReturns the media type of this request body.- Specified by:
contentTypein classRequestBody- Returns:
- The media type, which may be null.
-
writeTo
Description copied from class:RequestBodyWrites the content of this request body to the given sink.- Specified by:
writeToin classRequestBody- Parameters:
sink- The sink to write to.- Throws:
IOException- if an I/O error occurs during writing.
-