Repository: square/okhttp
File: okhttp/src/test/java/okhttp3/CacheTest.kt (Kotlin)

Code before:
        .build(),
    )
    val response1 = get(server.url("/"))
    assertThat(response1.body.string()).isEqualTo("abcd")
    assertThat(response1.headers).isEqualTo(
      headersOf(
        "Etag", "a", "Cache-Control", "max-age=0",
        "A", "a1", "B", "b2", "B", "b3", "Content-Length", "4",
      ),
    )

    // The original 'A' header is retained because the network response doesn't have one.
    // The original 'B' headers are replaced by the network response.
    // The network's 'C' header is added.
    val response2 = get(server.url("/"))
    assertThat(response2.body.string()).isEqualTo("abcd")
    assertThat(response2.headers).isEqualTo(
      headersOf(
        "Etag", "a", "Cache-Control", "max-age=0",
        "A", "a1", "Content-Length", "4", "B", "b4", "B", "b5", "C", "c6",
      ),
    )
  }

  @Test
  fun getHasCorrectResponseIsCorrect() {
    val request = Request(server.url("/abc"))

    val response = testBasicCachingRules(request)

    assertThat(response.request.url).isEqualTo(request.url)
    assertThat(response.cacheResponse!!.request.url).isEqualTo(request.url)
  }

  @Test
  fun postWithOverrideResponseIsCorrect() {
    val url = server.url("/abc?token=123")
    val cacheUrlOverride = url.newBuilder().removeAllQueryParameters("token").build()

    val request =
      Request.Builder()
        .url(url)
        .method("POST", "XYZ".toRequestBody())
        .cacheUrlOverride(cacheUrlOverride)
        .build()

    val response = testBasicCachingRules(request)

    assertThat(response.request.url).isEqualTo(request.url)
    assertThat(response.cacheResponse!!.request.url).isEqualTo(cacheUrlOverride)
  }

Review comment (suggestion):
```suggestion
  fun getHasCorrectResponse() {
```

Code after:
        .build(),
    )
    val response1 = get(server.url("/"))
    assertThat(response1.body.string()).isEqualTo("abcd")
    assertThat(response1.headers).isEqualTo(
      headersOf(
        "Etag", "a", "Cache-Control", "max-age=0",
        "A", "a1", "B", "b2", "B", "b3", "Content-Length", "4",
      ),
    )

    // The original 'A' header is retained because the network response doesn't have one.
    // The original 'B' headers are replaced by the network response.
    // The network's 'C' header is added.
    val response2 = get(server.url("/"))
    assertThat(response2.body.string()).isEqualTo("abcd")
    assertThat(response2.headers).isEqualTo(
      headersOf(
        "Etag", "a", "Cache-Control", "max-age=0",
        "A", "a1", "Content-Length", "4", "B", "b4", "B", "b5", "C", "c6",
      ),
    )
  }

  @Test
  fun getHasCorrectResponse() {
    val request = Request(server.url("/abc"))

    val response = testBasicCachingRules(request)

    assertThat(response.request.url).isEqualTo(request.url)
    assertThat(response.cacheResponse!!.request.url).isEqualTo(request.url)
  }

  @Test
  fun postWithOverrideResponse() {
    val url = server.url("/abc?token=123")
    val cacheUrlOverride = url.newBuilder().removeAllQueryParameters("token").build()

    val request =
      Request.Builder()
        .url(url)
        .method("POST", "XYZ".toRequestBody())
        .cacheUrlOverride(cacheUrlOverride)
        .build()

    val response = testBasicCachingRules(request)

    assertThat(response.request.url).isEqualTo(request.url)
    assertThat(response.cacheResponse!!.request.url).isEqualTo(cacheUrlOverride)
  }