From cc2bbff39339be500cf5e4ed2f3d5f215f46c12b Mon Sep 17 00:00:00 2001 From: Megatron King <1256980529@qq.com> Date: Thu, 8 Jun 2017 22:00:46 +0800 Subject: [PATCH] Fix a bug that if no Content-Length included in response header This bug will cause the cache file never completed. --- library/src/main/java/com/danikula/videocache/ProxyCache.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/danikula/videocache/ProxyCache.java b/library/src/main/java/com/danikula/videocache/ProxyCache.java index eeea971..57e0f57 100644 --- a/library/src/main/java/com/danikula/videocache/ProxyCache.java +++ b/library/src/main/java/com/danikula/videocache/ProxyCache.java @@ -153,7 +153,8 @@ private void onSourceRead() { private void tryComplete() throws ProxyCacheException { synchronized (stopLock) { - if (!isStopped() && cache.available() == source.length()) { + long sourceLength = source.length(); + if (!isStopped() && (cache.available() == sourceLength || sourceLength == -1)) { cache.complete(); } }