feat: пересылка клиентских заголовков в апстрим (кроме служебных); Authorization — только ключ провайдера
This commit is contained in:
@@ -4,6 +4,7 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
import io.ktor.http.headersOf
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
@@ -275,6 +276,42 @@ class ConfigLogicTest {
|
||||
assertEquals(null, pickFreeUpstream(pool, active, emptySet())?.id)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun headersToForwardKeepsUnknownAndDropsServiceHeaders() {
|
||||
val req = headersOf(
|
||||
"X-Opencode-Session" to listOf("abc-123"),
|
||||
"X-Custom" to listOf("a", "b"),
|
||||
"Host" to listOf("proxy:8100"),
|
||||
"Content-Length" to listOf("42"),
|
||||
"Transfer-Encoding" to listOf("chunked"),
|
||||
"Connection" to listOf("keep-alive"),
|
||||
"TE" to listOf("trailers"),
|
||||
"Proxy-Connection" to listOf("keep-alive"),
|
||||
"Upgrade" to listOf("h2c"),
|
||||
"Authorization" to listOf("Bearer client-secret"),
|
||||
"Accept" to listOf("*/*"),
|
||||
)
|
||||
val out = headersToForward(req)
|
||||
assertEquals(listOf("abc-123"), out["X-Opencode-Session"])
|
||||
assertEquals(listOf("a", "b"), out["X-Custom"])
|
||||
assertEquals(listOf("*/*"), out["Accept"])
|
||||
assertEquals(3, out.size)
|
||||
assertEquals(null, out["Authorization"])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun headersToForwardIsCaseInsensitiveOnSkipSet() {
|
||||
val out = headersToForward(
|
||||
headersOf(
|
||||
"HOST" to listOf("x"),
|
||||
"Content-length" to listOf("1"),
|
||||
"x-opencode-session" to listOf("s"),
|
||||
),
|
||||
)
|
||||
assertEquals(1, out.size)
|
||||
assertEquals(listOf("s"), out["x-opencode-session"])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rebuildFromChunksPreservesAllUpstreamFields() {
|
||||
val sse = """
|
||||
|
||||
Reference in New Issue
Block a user