Headers allow the same entry multiple times with different case
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- kotlin
- Domain
- networking
Research direction
Start with the Headers APIs used in the Kotlin example, especially headersOf and toHeaders, and trace how Request.Builder.headers handles names that differ only by case. Add a focused test based on the reproduction; done means the test establishes the intended behavior for repeated case-insensitive header names, which the issue does not specify fully.
Written by the indexing model from the issue text.
Description
HTTP header names are case-insensitive according to the HTTP specification (RFC 2616, RFC 7230).
So "User-Agent" and "user-agent" should be treated as the same key.
I don't know if this is the intended behavior, but okHttp is sending multiple times the same entry.
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Headers.Companion.toHeaders
import okhttp3.Headers.Companion.headersOf
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
private val client = OkHttpClient()
private val server = MockWebServer()
fun main() {
val defHeaders = mapOf(
"User-Agent" to "my-user-agent1",
"Referer" to "my-referer1"
)
server.enqueue(MockResponse())
println("### Headers from MockWebServer ###")
val myHeaders = mapOf(
"user-agent" to "my-user-agent2",
"User-Agent" to "my-user-agent3",
"referer" to "my-referer2"
)
val request1 = Request.Builder()
.url(server.url("/"))
.headers((defHeaders + myHeaders).toHeaders())
.build()
client.newCall(request1).execute()
val recordedRequest = server.takeRequest()
println(recordedRequest.headers)
server.close()
println("### Headers from httpbin ###")
val request2 = Request.Builder()
.url("https://httpbin.org/get")
.headers(headersOf(
"User-Agent", "my-user-agent1",
"user-agent", "my-user-agent2",
"User-Agent", "my-user-agent3",
"Referer", "my-referer1",
"referer", "my-referer2",
"Cookie", "key1=va1",
"cookie", "key2=val2"))
.build()
client.newCall(request2).execute().use { response ->
println(response.body?.string())
}
}
Terminal output:
### Headers from MockWebServer ###
User-Agent: my-user-agent1
Referer: my-referer1
user-agent: my-user-agent2
Host: localhost:63575
Connection: Keep-Alive
Accept-Encoding: gzip
### Headers from httpbin ###
{
"args": {},
"headers": {
"Accept-Encoding": "gzip",
"Cookie": "key1=va1; key2=val2",
"Host": "httpbin.org",
"Referer": "my-referer1,my-referer2",
"User-Agent": "my-user-agent1,my-user-agent2,my-user-agent3,my-user-agent4",
"X-Amzn-Trace-Id": "Root=########################"
},
"origin": "###.###.###.###",
"url": "https://httpbin.org/get"
}
- Dominant language
- Kotlin
- Stars
- 47.1k
- Forks
- 9.3k
- Avg merge
- 18h 18m
- Merged PRs (30d)
- 15
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lysine-dev/okhttp
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
lysine-dev/okhttp#9788 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
lysine-dev/okhttp#9761 · 3 comments ·
Maintainers usually reply within 1 day
-
Remove crossinline `addInterceptor` and `addNetworkInterceptor` overloadsPossibly taken @Amir-Golmoradi claimed this 5 days ago. Openenhancement
Difficulty 3/5 1-2 days Newbie friendliness 58/100
lysine-dev/okhttp#9779 · 1 comment ·
Maintainers usually reply within 1 day
-
HTTP/2 Data padding is not counted toward the connection flow-control window. This deadlocks connections with peers that pad.Possibly taken @Amir-Golmoradi claimed this 5 days ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 67/100
lysine-dev/okhttp#9772 · 4 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
lysine-dev/okhttp#9760 · 3 comments ·
Maintainers usually reply within 1 day
All issues in lysine-dev/okhttp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rustyrazorblade/easy-db-lab#1017 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
callstack/react-native-brownfield#492 · 1 comment ·
Maintainers usually reply within 4 days
-
fix: retain the best partial noise-correction solutionPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
world-federation-of-advertisers/cross-media-measurement#4653 ·
Maintainers usually reply within 1 day