diff --git a/http4k-client-apache4-async/src/main/kotlin/org/http4k/client/ApacheAsyncClient.kt b/http4k-client-apache4-async/src/main/kotlin/org/http4k/client/Apache4AsyncClient.kt similarity index 99% rename from http4k-client-apache4-async/src/main/kotlin/org/http4k/client/ApacheAsyncClient.kt rename to http4k-client-apache4-async/src/main/kotlin/org/http4k/client/Apache4AsyncClient.kt index 1b9601d159..465b173cb0 100644 --- a/http4k-client-apache4-async/src/main/kotlin/org/http4k/client/ApacheAsyncClient.kt +++ b/http4k-client-apache4-async/src/main/kotlin/org/http4k/client/Apache4AsyncClient.kt @@ -25,7 +25,7 @@ import org.http4k.core.Status.Companion.SERVICE_UNAVAILABLE import java.net.SocketTimeoutException import java.net.URI -object ApacheAsyncClient { +object Apache4AsyncClient { operator fun invoke( client: CloseableHttpAsyncClient = defaultApacheAsyncHttpClient(), responseBodyMode: BodyMode = Memory, diff --git a/http4k-client-apache4-async/src/test/kotlin/org/http4k/client/ApacheAsyncClientStreamingTest.kt b/http4k-client-apache4-async/src/test/kotlin/org/http4k/client/Apache4AsyncClientStreamingTest.kt similarity index 71% rename from http4k-client-apache4-async/src/test/kotlin/org/http4k/client/ApacheAsyncClientStreamingTest.kt rename to http4k-client-apache4-async/src/test/kotlin/org/http4k/client/Apache4AsyncClientStreamingTest.kt index fd423e50a6..911adb8a6d 100644 --- a/http4k-client-apache4-async/src/test/kotlin/org/http4k/client/ApacheAsyncClientStreamingTest.kt +++ b/http4k-client-apache4-async/src/test/kotlin/org/http4k/client/Apache4AsyncClientStreamingTest.kt @@ -5,9 +5,9 @@ import org.apache.http.impl.nio.reactor.IOReactorConfig import org.http4k.core.BodyMode import org.http4k.server.SunHttp -class ApacheAsyncClientStreamingTest : AsyncHttpClientContract({ SunHttp(it) }, - ApacheAsyncClient(responseBodyMode = BodyMode.Stream), - ApacheAsyncClient(HttpAsyncClients.custom() +class Apache4AsyncClientStreamingTest : AsyncHttpClientContract({ SunHttp(it) }, + Apache4AsyncClient(responseBodyMode = BodyMode.Stream), + Apache4AsyncClient(HttpAsyncClients.custom() .setDefaultIOReactorConfig(IOReactorConfig.custom() .setConnectTimeout(100) .setSoTimeout(100) diff --git a/http4k-client-apache4-async/src/test/kotlin/org/http4k/client/ApacheAsyncClientTest.kt b/http4k-client-apache4-async/src/test/kotlin/org/http4k/client/Apache4AsyncClientTest.kt similarity index 89% rename from http4k-client-apache4-async/src/test/kotlin/org/http4k/client/ApacheAsyncClientTest.kt rename to http4k-client-apache4-async/src/test/kotlin/org/http4k/client/Apache4AsyncClientTest.kt index b8aede55e6..f981f99427 100644 --- a/http4k-client-apache4-async/src/test/kotlin/org/http4k/client/ApacheAsyncClientTest.kt +++ b/http4k-client-apache4-async/src/test/kotlin/org/http4k/client/Apache4AsyncClientTest.kt @@ -19,8 +19,8 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.CountDownLatch import java.util.concurrent.Future -class ApacheAsyncClientTest : AsyncHttpClientContract({ SunHttp(it) }, ApacheAsyncClient(), - ApacheAsyncClient(HttpAsyncClients.custom() +class Apache4AsyncClientTest : AsyncHttpClientContract({ SunHttp(it) }, Apache4AsyncClient(), + Apache4AsyncClient(HttpAsyncClients.custom() .setDefaultIOReactorConfig(IOReactorConfig.custom() .setSoTimeout(100) .build()).build().apply { start() })) { @@ -28,7 +28,7 @@ class ApacheAsyncClientTest : AsyncHttpClientContract({ SunHttp(it) }, ApacheAsy fun `connect timeout is handled`() { val latch = CountDownLatch(1) - ApacheAsyncClient(object : CloseableHttpAsyncClient() { + Apache4AsyncClient(object : CloseableHttpAsyncClient() { override fun isRunning(): Boolean = false override fun start() {} diff --git a/http4k-client-apache4/src/main/kotlin/org/http4k/client/ApacheClient.kt b/http4k-client-apache4/src/main/kotlin/org/http4k/client/Apache4Client.kt similarity index 94% rename from http4k-client-apache4/src/main/kotlin/org/http4k/client/ApacheClient.kt rename to http4k-client-apache4/src/main/kotlin/org/http4k/client/Apache4Client.kt index e6570e1793..bf1009e925 100644 --- a/http4k-client-apache4/src/main/kotlin/org/http4k/client/ApacheClient.kt +++ b/http4k-client-apache4/src/main/kotlin/org/http4k/client/Apache4Client.kt @@ -25,7 +25,7 @@ import org.apache.http.impl.client.HttpClientBuilder import org.apache.http.impl.client.HttpClients import org.apache.http.impl.conn.PoolingHttpClientConnectionManager import org.apache.http.ssl.SSLContextBuilder -import org.http4k.client.PreCannedApacheHttpClients.defaultApacheHttpClient +import org.http4k.client.PreCannedApache4HttpClients.defaultApacheHttpClient import org.http4k.core.BodyMode import org.http4k.core.BodyMode.Memory import org.http4k.core.BodyMode.Stream @@ -46,7 +46,7 @@ import java.net.SocketTimeoutException import java.net.URI import java.net.UnknownHostException -object ApacheClient { +object Apache4Client { operator fun invoke( client: CloseableHttpClient = defaultApacheHttpClient(), responseBodyMode: BodyMode = Memory, @@ -75,7 +75,7 @@ object ApacheClient { OPTIONS -> HttpOptions(uri) TRACE -> HttpTrace(uri) DELETE -> HttpDelete(uri) - else -> ApacheRequest(requestBodyMode, request) + else -> Apache4Request(requestBodyMode, request) } request.headers.filter { !it.first.equals("content-length", true) }.map { apacheRequest.addHeader(it.first, it.second) } return apacheRequest @@ -90,7 +90,7 @@ object ApacheClient { } } -private class ApacheRequest(requestBodyMode: BodyMode, private val request: Request) : HttpEntityEnclosingRequestBase() { +private class Apache4Request(requestBodyMode: BodyMode, private val request: Request) : HttpEntityEnclosingRequestBase() { init { uri = URI(request.uri.toString()) entity = when (requestBodyMode) { @@ -102,7 +102,7 @@ private class ApacheRequest(requestBodyMode: BodyMode, private val request: Requ override fun getMethod() = request.method.name } -object PreCannedApacheHttpClients { +object PreCannedApache4HttpClients { /** * Standard non-redirecting, no Cookies HTTP client diff --git a/http4k-client-apache4/src/test/kotlin/org/http4k/client/ApacheClientStreamingContractTest.kt b/http4k-client-apache4/src/test/kotlin/org/http4k/client/Apache4ClientStreamingContractTest.kt similarity index 58% rename from http4k-client-apache4/src/test/kotlin/org/http4k/client/ApacheClientStreamingContractTest.kt rename to http4k-client-apache4/src/test/kotlin/org/http4k/client/Apache4ClientStreamingContractTest.kt index f903692176..1f36c06a84 100644 --- a/http4k-client-apache4/src/test/kotlin/org/http4k/client/ApacheClientStreamingContractTest.kt +++ b/http4k-client-apache4/src/test/kotlin/org/http4k/client/Apache4ClientStreamingContractTest.kt @@ -6,8 +6,8 @@ import org.http4k.server.ServerConfig import org.http4k.server.SunHttp import org.http4k.streaming.StreamingContract -class ApacheClientStreamingContractTest : StreamingContract() { +class Apache4ClientStreamingContractTest : StreamingContract() { override fun serverConfig(): ServerConfig = SunHttp(0) - override fun createClient(): HttpHandler = ApacheClient(requestBodyMode = BodyMode.Stream, responseBodyMode = BodyMode.Stream) + override fun createClient(): HttpHandler = Apache4Client(requestBodyMode = BodyMode.Stream, responseBodyMode = BodyMode.Stream) } diff --git a/http4k-client-apache4/src/test/kotlin/org/http4k/client/ApacheClientStreamingTest.kt b/http4k-client-apache4/src/test/kotlin/org/http4k/client/Apache4ClientStreamingTest.kt similarity index 69% rename from http4k-client-apache4/src/test/kotlin/org/http4k/client/ApacheClientStreamingTest.kt rename to http4k-client-apache4/src/test/kotlin/org/http4k/client/Apache4ClientStreamingTest.kt index b575b4f861..b3b45dd223 100644 --- a/http4k-client-apache4/src/test/kotlin/org/http4k/client/ApacheClientStreamingTest.kt +++ b/http4k-client-apache4/src/test/kotlin/org/http4k/client/Apache4ClientStreamingTest.kt @@ -5,9 +5,9 @@ import org.apache.http.impl.client.HttpClients import org.http4k.core.BodyMode.Stream import org.http4k.server.Jetty -class ApacheClientStreamingTest : HttpClientContract({ Jetty(it) }, - ApacheClient(requestBodyMode = Stream, responseBodyMode = Stream), - ApacheClient(HttpClients.custom() +class Apache4ClientStreamingTest : HttpClientContract({ Jetty(it) }, + Apache4Client(requestBodyMode = Stream, responseBodyMode = Stream), + Apache4Client(HttpClients.custom() .setDefaultSocketConfig( SocketConfig.custom() .setSoTimeout(100) diff --git a/http4k-client-apache4/src/test/kotlin/org/http4k/client/ApacheClientTest.kt b/http4k-client-apache4/src/test/kotlin/org/http4k/client/Apache4ClientTest.kt similarity index 88% rename from http4k-client-apache4/src/test/kotlin/org/http4k/client/ApacheClientTest.kt rename to http4k-client-apache4/src/test/kotlin/org/http4k/client/Apache4ClientTest.kt index ba684adffc..6784a7da16 100644 --- a/http4k-client-apache4/src/test/kotlin/org/http4k/client/ApacheClientTest.kt +++ b/http4k-client-apache4/src/test/kotlin/org/http4k/client/Apache4ClientTest.kt @@ -17,18 +17,18 @@ import org.http4k.hamkrest.hasStatus import org.http4k.server.Jetty import org.junit.jupiter.api.Test -class ApacheClientTest : HttpClientContract({ Jetty(it) }, ApacheClient(), - ApacheClient(HttpClients.custom() +class Apache4ClientTest : HttpClientContract({ Jetty(it) }, Apache4Client(), + Apache4Client(HttpClients.custom() .setDefaultSocketConfig( SocketConfig.custom() .setSoTimeout(100) .build() ).build() , responseBodyMode = Stream)) { - + @Test fun `connect timeout is handled`() { - assertThat(ApacheClient(object : CloseableHttpClient() { + assertThat(Apache4Client(object : CloseableHttpClient() { override fun getParams() = TODO("not implemented") override fun getConnectionManager() = TODO("not implemented") diff --git a/http4k-server-apache4/src/main/kotlin/org/http4k/server/ApacheServer.kt b/http4k-server-apache4/src/main/kotlin/org/http4k/server/Apache4Server.kt similarity index 93% rename from http4k-server-apache4/src/main/kotlin/org/http4k/server/ApacheServer.kt rename to http4k-server-apache4/src/main/kotlin/org/http4k/server/Apache4Server.kt index cc8b61f3db..fc4036fe40 100644 --- a/http4k-server-apache4/src/main/kotlin/org/http4k/server/ApacheServer.kt +++ b/http4k-server-apache4/src/main/kotlin/org/http4k/server/Apache4Server.kt @@ -28,7 +28,7 @@ import org.apache.http.HttpResponse as ApacheResponse /** * Exposed to allow for insertion into a customised Apache WebServer instance */ -class Http4kRequestHandler(handler: HttpHandler) : HttpRequestHandler { +class Http4kApache4RequestHandler(handler: HttpHandler) : HttpRequestHandler { private val safeHandler = ServerFilters.CatchAll().then(handler) @@ -62,7 +62,7 @@ class Http4kRequestHandler(handler: HttpHandler) : HttpRequestHandler { private fun Array
.toHttp4kHeaders(): Headers = listOf(*map { it.name to it.value }.toTypedArray()) } -data class ApacheServer(val port: Int = 8000, val address: InetAddress?) : ServerConfig { +data class Apache4Server(val port: Int = 8000, val address: InetAddress?) : ServerConfig { constructor(port: Int = 8000) : this(port, null) override fun toServer(httpHandler: HttpHandler): Http4kServer = object : Http4kServer { @@ -77,7 +77,7 @@ data class ApacheServer(val port: Int = 8000, val address: InetAddress?) : Serve .setSoReuseAddress(true) .setBacklogSize(1000) .build()) - .registerHandler("*", Http4kRequestHandler(httpHandler)) + .registerHandler("*", Http4kApache4RequestHandler(httpHandler)) if (address != null) bootstrap.setLocalAddress(address) diff --git a/http4k-server-apache4/src/test/kotlin/org/http4k/server/ApacheServerTest.kt b/http4k-server-apache4/src/test/kotlin/org/http4k/server/Apache4ServerTest.kt similarity index 67% rename from http4k-server-apache4/src/test/kotlin/org/http4k/server/ApacheServerTest.kt rename to http4k-server-apache4/src/test/kotlin/org/http4k/server/Apache4ServerTest.kt index 8c00700fbc..2b71ea7eed 100644 --- a/http4k-server-apache4/src/test/kotlin/org/http4k/server/ApacheServerTest.kt +++ b/http4k-server-apache4/src/test/kotlin/org/http4k/server/Apache4ServerTest.kt @@ -3,5 +3,5 @@ package org.http4k.server import org.http4k.client.ApacheClient import org.http4k.core.Method -class ApacheServerTest : ServerContract(::ApacheServer, ApacheClient(), - Method.values().filter { it != Method.PURGE }.toTypedArray()) \ No newline at end of file +class Apache4ServerTest : ServerContract(::Apache4Server, ApacheClient(), + Method.values().filter { it != Method.PURGE }.toTypedArray()) diff --git a/http4k-server-apache4/src/test/kotlin/org/http4k/stream/ApacheServerStreamingTest.kt b/http4k-server-apache4/src/test/kotlin/org/http4k/stream/Apache4ServerStreamingTest.kt similarity index 67% rename from http4k-server-apache4/src/test/kotlin/org/http4k/stream/ApacheServerStreamingTest.kt rename to http4k-server-apache4/src/test/kotlin/org/http4k/stream/Apache4ServerStreamingTest.kt index 7da5803a13..7d720bf167 100644 --- a/http4k-server-apache4/src/test/kotlin/org/http4k/stream/ApacheServerStreamingTest.kt +++ b/http4k-server-apache4/src/test/kotlin/org/http4k/stream/Apache4ServerStreamingTest.kt @@ -3,13 +3,13 @@ package org.http4k.stream import org.http4k.client.ApacheClient import org.http4k.core.BodyMode.Stream import org.http4k.core.HttpHandler -import org.http4k.server.ApacheServer +import org.http4k.server.Apache4Server import org.http4k.server.ServerConfig import org.http4k.streaming.StreamingContract -class ApacheServerStreamingTest : StreamingContract() { - override fun serverConfig(): ServerConfig = ApacheServer(0) +class Apache4ServerStreamingTest : StreamingContract() { + override fun serverConfig(): ServerConfig = Apache4Server(0) override fun createClient(): HttpHandler = ApacheClient(requestBodyMode = Stream, responseBodyMode = Stream) -} \ No newline at end of file +} diff --git a/src/docs/guide/modules/clients/example_http.kt b/src/docs/guide/modules/clients/example_http.kt index 831f461bbf..61d3caafae 100644 --- a/src/docs/guide/modules/clients/example_http.kt +++ b/src/docs/guide/modules/clients/example_http.kt @@ -1,8 +1,8 @@ package guide.modules.clients import org.apache.hc.client5.http.config.RequestConfig +import org.apache.hc.client5.http.cookie.StandardCookieSpec import org.apache.hc.client5.http.impl.classic.HttpClients -import org.apache.http.client.config.CookieSpecs import org.http4k.client.ApacheAsyncClient import org.http4k.client.ApacheClient import org.http4k.core.BodyMode @@ -44,7 +44,7 @@ fun main() { val customClient = ApacheClient( client = HttpClients.custom().setDefaultRequestConfig(RequestConfig.custom() .setRedirectsEnabled(false) - .setCookieSpec(CookieSpecs.IGNORE_COOKIES) + .setCookieSpec(StandardCookieSpec.IGNORE) .build()) .build() )