java.lang.Object
org.miaixz.bus.http.plugin.httpz.FileInterceptor
- All Implemented Interfaces:
Interceptor,ProgressListener
An abstract
Interceptor that adds a download progress listener to the response body. Subclasses must
implement the updateProgress(long, long, boolean) method to handle progress updates.- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAResponseBodydecorator that reports download progress as the body is being read. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIntercepts the network response to wrap the original response body with a progress-monitoring body.abstract voidupdateProgress(long downloadLenth, long totalLength, boolean isFinish) An abstract callback method that is invoked with download progress updates.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.miaixz.bus.http.metric.Interceptor
instructions
-
Constructor Details
-
FileInterceptor
public FileInterceptor()
-
-
Method Details
-
intercept
Intercepts the network response to wrap the original response body with a progress-monitoring body.- Specified by:
interceptin interfaceInterceptor- Parameters:
chain- The interceptor chain.- Returns:
- The modified
Responsewith a progress-aware body. - Throws:
IOException- if an I/O error occurs during the request.
-
updateProgress
public abstract void updateProgress(long downloadLenth, long totalLength, boolean isFinish) An abstract callback method that is invoked with download progress updates.- Specified by:
updateProgressin interfaceProgressListener- Parameters:
downloadLenth- The number of bytes downloaded so far.totalLength- The total size of the file in bytes.isFinish-trueif the download is complete,falseotherwise.
-