mirror of
https://github.com/apple/pkl.git
synced 2026-05-25 16:19:20 +02:00
Remove public modifier on LazyHttpClient and RequestRewritingClient (#1609)
This introduces a test helper to expose configured HTTP settings, and makes the underlying classes package-private again.
This commit is contained in:
@@ -21,8 +21,7 @@ import java.time.Duration
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import org.pkl.core.http.LazyHttpClient
|
||||
import org.pkl.core.http.RequestRewritingClient
|
||||
import org.pkl.core.http.getConfiguredSettings
|
||||
import org.pkl.core.project.Project
|
||||
import org.pkl.core.resource.TestResourceReader
|
||||
import org.pkl.core.util.IoUtils
|
||||
@@ -97,10 +96,10 @@ class EvaluatorBuilderTest {
|
||||
.isEqualTo(3) // two external readers, one module path
|
||||
assertThat(builder.resourceReaders.find { it.uriScheme == "scheme3" }).isNotNull
|
||||
assertThat(builder.resourceReaders.find { it.uriScheme == "scheme4" }).isNotNull
|
||||
val client = (builder.httpClient as LazyHttpClient).orCreateClient as RequestRewritingClient
|
||||
assertThat(client.headers)
|
||||
val settings = builder.httpClient.getConfiguredSettings()
|
||||
assertThat(settings.headers)
|
||||
.isEqualTo(mapOf(IoUtils.doubleStarGlob to mapOf("X-Foo" to listOf("Foo"))))
|
||||
assertThat(client.rewritesMap)
|
||||
assertThat(settings.rewritesMap)
|
||||
.isEqualTo(mapOf(URI("https://foo.com/") to URI("https://bar.com/")))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright © 2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.pkl.core.http
|
||||
|
||||
import java.net.URI
|
||||
import java.util.regex.Pattern
|
||||
|
||||
data class HttpSettings(
|
||||
val headers: Map<Pattern, Map<String, List<String>>>,
|
||||
val rewritesMap: Map<URI, URI>,
|
||||
)
|
||||
|
||||
fun HttpClient.getConfiguredSettings(): HttpSettings {
|
||||
this as LazyHttpClient
|
||||
val requestRewritingClient = this.orCreateClient as RequestRewritingClient
|
||||
return HttpSettings(requestRewritingClient.headers, requestRewritingClient.rewritesMap)
|
||||
}
|
||||
Reference in New Issue
Block a user