// Path: lib_common/src/main/java/com/guiying/module/common/utils/CloseUtils.java
// public class CloseUtils {
// 
//     private CloseUtils() {
//         throw new UnsupportedOperationException("u can't instantiate me...");
//     }
// 
//     /**
//      * 关闭IO
//      *
//      * @param closeables closeable
//      */
//     public static void closeIO(Closeable... closeables) {
//         if (closeables == null) return;
//         for (Closeable closeable : closeables) {
//             if (closeable != null) {
//                 try {
//                     closeable.close();
//                 } catch (IOException e) {
//                     e.printStackTrace();
//                 }
//             }
//         }
//     }
// 
//     /**
//      * 安静关闭IO
//      *
//      * @param closeables closeable
//      */
//     public static void closeIOQuietly(Closeable... closeables) {
//         if (closeables == null) return;
//         for (Closeable closeable : closeables) {
//             if (closeable != null) {
//                 try {
//                     closeable.close();
//                 } catch (IOException ignored) {
//                 }
//             }
//         }
//     }
// }


import com.bumptech.glide.Priority;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.util.ContentLengthInputStream;
import com.guiying.module.common.utils.CloseUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
                .url(url.toStringUrl());

        for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
            String key = headerEntry.getKey();
            requestBuilder.addHeader(key, headerEntry.getValue());
        }

        Request request = requestBuilder.build();

        Response response = client.newCall(request).execute();
        responseBody = response.body();
        if (!response.isSuccessful()) {
            throw new IOException("Request failed with code: " + response.code());
        }

        long contentLength = responseBody.contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        return stream;
    }

    @Override
    public void cleanup() {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
                // Ignored
            }
        }
        if (responseBody != null) {
// Path: lib_common/src/main/java/com/guiying/module/common/utils/CloseUtils.java
// public class CloseUtils {
// 
//     private CloseUtils() {
//         throw new UnsupportedOperationException("u can't instantiate me...");
//     }
// 
//     /**
//      * 关闭IO
//      *
//      * @param closeables closeable
//      */
//     public static void closeIO(Closeable... closeables) {
//         if (closeables == null) return;
//         for (Closeable closeable : closeables) {
//             if (closeable != null) {
//                 try {
//                     closeable.close();
//                 } catch (IOException e) {
//                     e.printStackTrace();
//                 }
//             }
//         }
//     }
// 
//     /**
//      * 安静关闭IO
//      *
//      * @param closeables closeable
//      */
//     public static void closeIOQuietly(Closeable... closeables) {
//         if (closeables == null) return;
//         for (Closeable closeable : closeables) {
//             if (closeable != null) {
//                 try {
//                     closeable.close();
//                 } catch (IOException ignored) {
//                 }
//             }
//         }
//     }
// }


// Path: lib_common/src/main/java/com/guiying/module/common/glide/OkHttpStreamFetcher.java
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.util.ContentLengthInputStream;
import com.guiying.module.common.utils.CloseUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

                .url(url.toStringUrl());

        for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) {
            String key = headerEntry.getKey();
            requestBuilder.addHeader(key, headerEntry.getValue());
        }

        Request request = requestBuilder.build();

        Response response = client.newCall(request).execute();
        responseBody = response.body();
        if (!response.isSuccessful()) {
            throw new IOException("Request failed with code: " + response.code());
        }

        long contentLength = responseBody.contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        return stream;
    }

    @Override
    public void cleanup() {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
                // Ignored
            }
        }
        if (responseBody != null) {
            CloseUtils.closeIO(responseBody);