Skip to content

Commit

Permalink
Merge branch 'main' into 3.x
Browse files Browse the repository at this point in the history
* main:
  Bump androidx.benchmark:benchmark-macro-junit4 (#1841)
  Bump androidx.compose.ui:ui-test-junit4 from 1.4.3 to 1.5.0 (#1842)
  Bump compose from 1.4.3 to 1.5.0 (#1840)
  Disk cache load fails after 304 Not Modified when cached headers include non-ASCII characters (#1839)
  Remove the Okio Proguard rule. (#1837)
  Bump okio from 3.4.0 to 3.5.0 (#1836)
  Bump androidx.recyclerview:recyclerview from 1.3.0 to 1.3.1 (#1832)
  Bump androidx.benchmark:benchmark-macro-junit4 (#1831)
  Fix coil-benchmark.
  • Loading branch information
colinrtwhite committed Aug 10, 2023
2 parents 041ba30 + d25b5e4 commit 541aa9a
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ val drawable = imageLoader.execute(request).drawable

Coil は R8 と完全に互換性があり、追加のルールを追加する必要はありません。

Proguardを使用している場合は、[Coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro)[OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro)[Okio](https://github.com/square/okio/blob/master/okio/src/jvmMain/resources/META-INF/proguard/okio.pro)にルールを追加する必要があるかもしれません。
Proguardを使用している場合は、[Coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro)[OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro)にルールを追加する必要があるかもしれません。

## ライセンス

Expand Down
2 changes: 1 addition & 1 deletion README-ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ val drawable = imageLoader.execute(request).drawable

Coil은 별도의 설정 없이 R8과 완벽하게 호환 가능하며 추가 규칙이 필요하지 않습니다.

Proguard를 사용할 경우, [Coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro), [OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro), [Okio](https://github.com/square/okio/blob/master/okio/src/jvmMain/resources/META-INF/proguard/okio.pro) 규칙을 추가할 필요가 있을 수 있습니다.
Proguard를 사용할 경우, [Coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro) [OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro) 규칙을 추가할 필요가 있을 수 있습니다.

## 라이선스

Expand Down
2 changes: 1 addition & 1 deletion README-tr.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Coil'in [dokümantasyonunun tamamına buradan](https://coil-kt.github.io/coil/ge

Coil R8 ile tamamen uyumludur ve ek kurallar eklemeyi gerektirmez.

Eğer Proguard kullanıyorsanız, [Coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro), [OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro) ve [Okio](https://github.com/square/okio/blob/master/okio/src/jvmMain/resources/META-INF/proguard/okio.pro) için kurallar eklemeniz gerekebilir.
Eğer Proguard kullanıyorsanız, [Coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro) ve [OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro) için kurallar eklemeniz gerekebilir.

## Lisans

Expand Down
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ val drawable = imageLoader.execute(request).drawable

Coil 兼容 R8 混淆,您无需再添加其他的规则

如果您需要混淆代码,可能需要添加对应的混淆规则:[Coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro), [OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro), [Okio](https://github.com/square/okio/blob/master/okio/src/jvmMain/resources/META-INF/proguard/okio.pro)
如果您需要混淆代码,可能需要添加对应的混淆规则:[Coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro), [OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro)

## License

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Check out Coil's [full documentation here](https://coil-kt.github.io/coil/gettin

Coil is fully compatible with R8 out of the box and doesn't require adding any extra rules.

If you use Proguard, you may need to add rules for [Coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro), [OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro) and [Okio](https://github.com/square/okio/blob/master/okio/src/jvmMain/resources/META-INF/proguard/okio.pro).
If you use Proguard, you may need to add rules for [Coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro) and [OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro).

## License

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,53 @@ class HttpUriFetcherTest {
assertEquals(expectedHeaders.toSet(), cacheResponse.responseHeaders.toSet())
}

/** Regression test: https://github.com/coil-kt/coil/issues/1838 */
@Test
fun `cache control - HTTP_NOT_MODIFIED response combines headers with cached response with non-ASCII cached headers`() = runTestAsync {
val url = server.url(IMAGE).toString()
val headers = Headers.Builder()
.set("Cache-Control", "no-cache")
.set("Cache-Header", "none")
.set("ETag", "fake_etag")
.addUnsafeNonAscii(
"Content-Disposition",
"inline; filename=\"alimentación.webp\""
)
.build()
val expectedSize = server.enqueueImage(IMAGE, headers)
var result = newFetcher(url).fetch()

assertEquals(1, server.requestCount)
assertIs<SourceResult>(result)
assertEquals(DataSource.NETWORK, result.dataSource)
assertEquals(expectedSize, result.source.use { it.source().readAll(blackholeSink()) })
diskCache.openSnapshot(url).use(::assertNotNull)

// Don't set a response body as it should be read from the cache.
val response = MockResponse()
.setResponseCode(HTTP_NOT_MODIFIED)
.addHeader("Response-Header", "none")
server.enqueue(response)
result = newFetcher(url).fetch()

assertIs<SourceResult>(result)
assertEquals(DataSource.NETWORK, result.dataSource)
assertEquals(expectedSize, result.source.use { it.source().readAll(blackholeSink()) })

server.takeRequest() // Discard the first request.

assertEquals(2, server.requestCount)
val cacheResponse = diskCache.openSnapshot(url)!!.use { snapshot ->
CacheResponse(diskCache.fileSystem.source(snapshot.metadata).buffer())
}
val expectedHeaders = headers.newBuilder()
.addAll(response.headers)
// Content-Length is set later by OkHttp.
.set("Content-Length", expectedSize.toString())
.build()
assertEquals(expectedHeaders.toSet(), cacheResponse.responseHeaders.toSet())
}

@Test
fun `cache control - unexpired max-age is returned from cache`() = runTestAsync {
val url = server.url(IMAGE).toString()
Expand Down
4 changes: 2 additions & 2 deletions coil-base/src/commonMain/kotlin/coil/network/CacheStrategy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ internal class CacheStrategy private constructor(
continue
}
if (isContentSpecificHeader(name) || !isEndToEnd(name) || networkHeaders[name] == null) {
result.add(name, value)
result.addUnsafeNonAscii(name, value)
}
}

for (index in 0 until networkHeaders.size) {
val fieldName = networkHeaders.name(index)
if (!isContentSpecificHeader(fieldName) && isEndToEnd(fieldName)) {
result.add(fieldName, networkHeaders.value(index))
result.addUnsafeNonAscii(fieldName, networkHeaders.value(index))
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ org.jetbrains.compose.experimental.uikit.enabled=true

# Config
minSdk=21
targetSdk=33
compileSdk=33
targetSdk=34
compileSdk=34

# Maven
SONATYPE_HOST=DEFAULT
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[versions]
androidx-activity = "1.7.2"
androidx-lifecycle = "2.6.1"
androidx-compose = "1.4.3"
androidx-compose = "1.5.0"
androidx-compose-compiler = "1.5.0"
coroutines = "1.7.3"
jetbrains-compose = "1.4.3"
jetbrains-compose = "1.5.0-beta01"
jetbrains-compose-compiler = "1.5.0"
ktlint = "0.50.0"
okio = "3.4.0"
okio = "3.5.0"
roborazzi = "1.3.0"

[plugins]
Expand All @@ -30,15 +30,15 @@ androidx-activity = { module = "androidx.activity:activity-ktx", version.ref = "
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
androidx-appcompat-resources = "androidx.appcompat:appcompat-resources:1.6.1"
androidx-annotation = "androidx.annotation:annotation:1.6.0"
androidx-benchmark-macro = "androidx.benchmark:benchmark-macro-junit4:1.2.0-beta01"
androidx-benchmark-macro = "androidx.benchmark:benchmark-macro-junit4:1.2.0-beta03"
androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4"
androidx-core = "androidx.core:core-ktx:1.10.1"
androidx-exifinterface = "androidx.exifinterface:exifinterface:1.3.6"
androidx-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime", version.ref = "androidx-lifecycle" }
androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" }
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" }
androidx-profileinstaller = "androidx.profileinstaller:profileinstaller:1.3.1"
androidx-recyclerview = "androidx.recyclerview:recyclerview:1.3.0"
androidx-recyclerview = "androidx.recyclerview:recyclerview:1.3.1"
androidx-test-core = "androidx.test:core-ktx:1.5.0"
androidx-test-espresso = "androidx.test.espresso:espresso-core:3.5.1"
androidx-test-junit = "androidx.test.ext:junit-ktx:1.1.5"
Expand Down

0 comments on commit 541aa9a

Please sign in to comment.