-
Notifications
You must be signed in to change notification settings - Fork 719
Closed
Labels
help wantedIssues that are up for grabs + are good candidates for community PRsIssues that are up for grabs + are good candidates for community PRs
Description
Describe the bug
Scenario:
- image caching disabled in coil
- requesting image via url (HttpUrlFetcher)
- server returns valid chunked response (doesn't contain
Content-Length
header)
results in two requests to given url (despite the first one being successful)
To Reproduce
val request = ImageRequest.Builder(context)
.data("https://www.httpwatch.com/httpgallery/chunked/chunkedimage.aspx")
.memoryCachePolicy(CachePolicy.DISABLED)
.diskCachePolicy(CachePolicy.DISABLED)
.build()
context.imageLoader.execute(request)
Logs/Screenshots
The cause seems to be the verification in https://github.com/coil-kt/coil/blob/main/coil-base/src/main/java/coil/fetch/HttpUriFetcher.kt#L95 which relies on explicit content length being provided in response. In the scenario above the length isn't known (okhttp reports it as -1)
Version
2.2.2
It might be enough to allow contentLength() == -1
in the check mentioned above (it seems to fix the problem in my case) or possibly also peeking the response body buffer to make sure it's not empty
Metadata
Metadata
Assignees
Labels
help wantedIssues that are up for grabs + are good candidates for community PRsIssues that are up for grabs + are good candidates for community PRs