diff --git a/README.MD b/README.MD
index b151184..127e61c 100644
--- a/README.MD
+++ b/README.MD
@@ -59,7 +59,7 @@ Also [GitHub - SSLContext Kickstart](https://github.com/Hakky54/sslcontext-kicks
# Tutorial
## Starting the server
**Minimum requirements:**
-1. Java 11
+1. Java 17
2. Maven 3.5.0
3. Eclipse, Intellij IDEA (or any other text editor like VIM)
4. A terminal
diff --git a/client/pom.xml b/client/pom.xml
index 6389ff5..af85bc2 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -29,10 +29,18 @@
org.apache.httpcomponents
httpclient
+
+ org.apache.httpcomponents.client5
+ httpclient5
+
org.eclipse.jetty
jetty-reactive-httpclient
+
+ org.eclipse.jetty
+ jetty-client
+
org.glassfish.jersey.core
jersey-client
diff --git a/client/src/main/java/nl/altindag/client/ClientConfig.java b/client/src/main/java/nl/altindag/client/ClientConfig.java
index df6c3fd..4a9c730 100644
--- a/client/src/main/java/nl/altindag/client/ClientConfig.java
+++ b/client/src/main/java/nl/altindag/client/ClientConfig.java
@@ -130,16 +130,15 @@ public HttpClient jdkHttpClient(SSLFactory sslFactory) {
}
@Bean
- public RestTemplate restTemplate(org.apache.http.impl.client.CloseableHttpClient httpClient) {
+ public RestTemplate restTemplate(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient) {
return new RestTemplate(new HttpComponentsClientHttpRequestFactory(httpClient));
}
- @Bean
+ @Bean("okHttpClient")
@Scope("prototype")
public OkHttpClient okHttpClient(SSLFactory sslFactory) {
return new OkHttpClient.Builder()
.sslSocketFactory(sslFactory.getSslSocketFactory(), sslFactory.getTrustManager().orElseThrow())
- .hostnameVerifier(sslFactory.getHostnameVerifier())
.build();
}
@@ -155,17 +154,19 @@ public reactor.netty.http.client.HttpClient nettyHttpClient(SSLFactory sslFactor
@Scope("prototype")
public org.eclipse.jetty.client.HttpClient jettyHttpClient(SSLFactory sslFactory) {
var sslContextFactory = JettySslUtils.forClient(sslFactory);
- return new org.eclipse.jetty.client.HttpClient(sslContextFactory);
+ org.eclipse.jetty.client.HttpClient httpClient = new org.eclipse.jetty.client.HttpClient();
+ httpClient.setSslContextFactory(sslContextFactory);
+ return httpClient;
}
- @Bean
+ @Bean("webClientWithNetty")
public WebClient webClientWithNetty(reactor.netty.http.client.HttpClient httpClient) {
return WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(httpClient))
.build();
}
- @Bean
+ @Bean("webClientWithJetty")
public WebClient webClientWithJetty(org.eclipse.jetty.client.HttpClient httpClient) {
return WebClient.builder()
.clientConnector(new JettyClientHttpConnector(httpClient))
@@ -235,7 +236,7 @@ public void unirest(SSLFactory sslFactory) {
}
@Bean
- public Retrofit retrofit(OkHttpClient okHttpClient) {
+ public Retrofit retrofit(@Qualifier("okHttpClient") OkHttpClient okHttpClient) {
return new Retrofit.Builder()
.client(okHttpClient)
.baseUrl(Constants.getServerUrl())
@@ -288,7 +289,7 @@ public Feign.Builder feignWithOldJdkHttpClient(SSLFactory sslFactory) {
}
@Bean
- public Feign.Builder feignWithOkHttpClient(OkHttpClient okHttpClient) {
+ public Feign.Builder feignWithOkHttpClient(@Qualifier("okHttpClient") OkHttpClient okHttpClient) {
return Feign.builder()
.client(new feign.okhttp.OkHttpClient(okHttpClient));
}
diff --git a/client/src/main/java/nl/altindag/client/service/Http4kAsyncClientService.kt b/client/src/main/java/nl/altindag/client/service/Http4kAsyncClientService.kt
index de549be..fb8db87 100644
--- a/client/src/main/java/nl/altindag/client/service/Http4kAsyncClientService.kt
+++ b/client/src/main/java/nl/altindag/client/service/Http4kAsyncClientService.kt
@@ -18,12 +18,12 @@ package nl.altindag.client.service
import nl.altindag.client.Constants
import nl.altindag.client.model.ClientResponse
import org.awaitility.Awaitility.await
-import org.http4k.client.AsyncHttpClient
+import org.http4k.client.AsyncHttpHandler
import org.http4k.core.Method
import org.http4k.core.Request
import java.util.concurrent.TimeUnit
-abstract class Http4kAsyncClientService(val client: AsyncHttpClient): RequestService {
+abstract class Http4kAsyncClientService(val client: AsyncHttpHandler): RequestService {
override fun executeRequest(url: String): ClientResponse {
var response: ClientResponse? = null
diff --git a/client/src/main/java/nl/altindag/client/service/Http4kJettyHttpClientService.kt b/client/src/main/java/nl/altindag/client/service/Http4kJettyHttpClientService.kt
index 01c2c07..869c5b5 100644
--- a/client/src/main/java/nl/altindag/client/service/Http4kJettyHttpClientService.kt
+++ b/client/src/main/java/nl/altindag/client/service/Http4kJettyHttpClientService.kt
@@ -17,21 +17,19 @@ package nl.altindag.client.service
import nl.altindag.client.ClientType
import nl.altindag.client.ClientType.HTTP4K_JETTY_HTTP_CLIENT
-import nl.altindag.ssl.SSLFactory
-import nl.altindag.ssl.jetty.util.JettySslUtils
import org.eclipse.jetty.client.HttpClient
import org.http4k.client.JettyClient
import org.springframework.stereotype.Service
@Service
class Http4kJettyHttpClientService(
- sslFactory: SSLFactory
+ jettyClient: HttpClient
) : Http4kClientService(
JettyClient(
- client = HttpClient(JettySslUtils.forClient(sslFactory))
+ client = jettyClient
)
) {
override fun getClientType(): ClientType = HTTP4K_JETTY_HTTP_CLIENT
-}
\ No newline at end of file
+}
diff --git a/client/src/main/java/nl/altindag/client/service/JettyReactiveHttpClientService.java b/client/src/main/java/nl/altindag/client/service/JettyReactiveHttpClientService.java
index ec2d820..e231521 100644
--- a/client/src/main/java/nl/altindag/client/service/JettyReactiveHttpClientService.java
+++ b/client/src/main/java/nl/altindag/client/service/JettyReactiveHttpClientService.java
@@ -39,7 +39,7 @@ public ClientResponse executeRequest(String url) throws Exception {
var contentResponse = httpClient.newRequest(url)
.method(HttpMethod.GET)
- .header(HEADER_KEY_CLIENT_TYPE, getClientType().getValue())
+ .headers(header -> header.add(HEADER_KEY_CLIENT_TYPE, getClientType().getValue()))
.send();
httpClient.stop();
diff --git a/client/src/main/java/nl/altindag/client/service/OkHttpClientService.java b/client/src/main/java/nl/altindag/client/service/OkHttpClientService.java
index c40cd1e..511ac5b 100644
--- a/client/src/main/java/nl/altindag/client/service/OkHttpClientService.java
+++ b/client/src/main/java/nl/altindag/client/service/OkHttpClientService.java
@@ -19,6 +19,7 @@
import nl.altindag.client.model.ClientResponse;
import okhttp3.OkHttpClient;
import okhttp3.Request;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.io.IOException;
@@ -32,7 +33,7 @@ public class OkHttpClientService implements RequestService {
private final OkHttpClient okHttpClient;
- public OkHttpClientService(OkHttpClient okHttpClient) {
+ public OkHttpClientService(@Qualifier("okHttpClient") OkHttpClient okHttpClient) {
this.okHttpClient = okHttpClient;
}
diff --git a/client/src/main/java/nl/altindag/client/service/SpringWebClientJettyService.java b/client/src/main/java/nl/altindag/client/service/SpringWebClientJettyService.java
index 615c90e..ccb3972 100644
--- a/client/src/main/java/nl/altindag/client/service/SpringWebClientJettyService.java
+++ b/client/src/main/java/nl/altindag/client/service/SpringWebClientJettyService.java
@@ -17,6 +17,7 @@
import static nl.altindag.client.ClientType.SPRING_WEB_CLIENT_JETTY;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
@@ -25,7 +26,7 @@
@Service
public class SpringWebClientJettyService extends SpringWebClientService {
- public SpringWebClientJettyService(WebClient webClientWithJetty) {
+ public SpringWebClientJettyService(@Qualifier("webClientWithJetty") WebClient webClientWithJetty) {
super(webClientWithJetty);
}
diff --git a/client/src/main/java/nl/altindag/client/service/SpringWebClientNettyService.java b/client/src/main/java/nl/altindag/client/service/SpringWebClientNettyService.java
index 74d0d48..2893441 100644
--- a/client/src/main/java/nl/altindag/client/service/SpringWebClientNettyService.java
+++ b/client/src/main/java/nl/altindag/client/service/SpringWebClientNettyService.java
@@ -17,6 +17,7 @@
import static nl.altindag.client.ClientType.SPRING_WEB_CLIENT_NETTY;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
@@ -25,7 +26,7 @@
@Service
public class SpringWebClientNettyService extends SpringWebClientService {
- public SpringWebClientNettyService(WebClient webClientWithNetty) {
+ public SpringWebClientNettyService(@Qualifier("webClientWithNetty") WebClient webClientWithNetty) {
super(webClientWithNetty);
}
diff --git a/client/src/test/java/nl/altindag/client/ClientConfigShould.java b/client/src/test/java/nl/altindag/client/ClientConfigShould.java
index 252b48f..1723f72 100644
--- a/client/src/test/java/nl/altindag/client/ClientConfigShould.java
+++ b/client/src/test/java/nl/altindag/client/ClientConfigShould.java
@@ -112,7 +112,7 @@ void createJdkHttpClient() {
@Test
void createRestTemplate() {
- CloseableHttpClient httpClient = mock(CloseableHttpClient.class);
+ org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient = mock(org.apache.hc.client5.http.impl.classic.CloseableHttpClient.class);
RestTemplate restTemplate = victim.restTemplate(httpClient);
@@ -127,12 +127,10 @@ void createOkHttpClient() {
assertThat(okHttpClient).isNotNull();
verify(sslFactory, times(1)).getTrustManager();
- verify(sslFactory, times(1)).getHostnameVerifier();
verify(sslFactory, times(1)).getSslSocketFactory();
assertThat(sslFactory.getTrustManager()).isPresent();
assertThat(okHttpClient.x509TrustManager()).isEqualTo(sslFactory.getTrustManager().get());
- assertThat(okHttpClient.hostnameVerifier()).isEqualTo(sslFactory.getHostnameVerifier());
}
@Test
diff --git a/client/src/test/java/nl/altindag/client/service/Http4kJettyHttpClientServiceShould.kt b/client/src/test/java/nl/altindag/client/service/Http4kJettyHttpClientServiceShould.kt
index f11cf4f..ec22530 100644
--- a/client/src/test/java/nl/altindag/client/service/Http4kJettyHttpClientServiceShould.kt
+++ b/client/src/test/java/nl/altindag/client/service/Http4kJettyHttpClientServiceShould.kt
@@ -19,7 +19,9 @@ import nl.altindag.client.ClientType.HTTP4K_JETTY_HTTP_CLIENT
import nl.altindag.client.TestConstants
import nl.altindag.client.util.MockServerTestHelper
import nl.altindag.client.util.SSLFactoryTestHelper
+import nl.altindag.ssl.jetty.util.JettySslUtils
import org.assertj.core.api.Assertions.assertThat
+import org.eclipse.jetty.client.HttpClient
import org.junit.jupiter.api.Test
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
@@ -31,7 +33,11 @@ class Http4kJettyHttpClientServiceShould {
MockServerTestHelper.mockResponseForClient(HTTP4K_JETTY_HTTP_CLIENT)
val sslFactory = SSLFactoryTestHelper.createSSLFactory(false, true)
- val client = Http4kJettyHttpClientService(sslFactory)
+ val sslContextFactory = JettySslUtils.forClient(sslFactory)
+ val httpClient = HttpClient()
+ httpClient.sslContextFactory = sslContextFactory
+
+ val client = Http4kJettyHttpClientService(httpClient)
val response = client.executeRequest(TestConstants.HTTP_URL)
assertThat(response.responseBody).isEqualTo("Hello")
diff --git a/client/src/test/java/nl/altindag/client/service/JettyReactiveHttpClientServiceShould.java b/client/src/test/java/nl/altindag/client/service/JettyReactiveHttpClientServiceShould.java
index 6f05ffa..13f18a0 100644
--- a/client/src/test/java/nl/altindag/client/service/JettyReactiveHttpClientServiceShould.java
+++ b/client/src/test/java/nl/altindag/client/service/JettyReactiveHttpClientServiceShould.java
@@ -16,9 +16,9 @@
package nl.altindag.client.service;
import nl.altindag.client.model.ClientResponse;
+import org.eclipse.jetty.client.ContentResponse;
import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.http.HttpMethod;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -27,8 +27,8 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import static nl.altindag.client.ClientType.JETTY_REACTIVE_HTTP_CLIENT;
-import static nl.altindag.client.TestConstants.HEADER_KEY_CLIENT_TYPE;
+import java.util.function.Consumer;
+
import static nl.altindag.client.TestConstants.HTTP_URL;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
@@ -38,6 +38,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+@SuppressWarnings("unchecked")
@ExtendWith(MockitoExtension.class)
class JettyReactiveHttpClientServiceShould {
@@ -53,14 +54,12 @@ void executeRequest() throws Exception {
when(httpClient.newRequest(anyString())).thenReturn(request);
when(request.method(any(HttpMethod.class))).thenReturn(request);
- when(request.header(anyString(), anyString())).thenReturn(request);
+ when(request.headers(any(Consumer.class))).thenReturn(request);
when(request.send()).thenReturn(contentResponse);
when(contentResponse.getContentAsString()).thenReturn("hello");
when(contentResponse.getStatus()).thenReturn(200);
ArgumentCaptor urlCaptor = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor headerKeyCaptor = ArgumentCaptor.forClass(String.class);
- ArgumentCaptor headerValueCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor httpMethodCaptor = ArgumentCaptor.forClass(HttpMethod.class);
ClientResponse clientResponse = victim.executeRequest(HTTP_URL);
@@ -68,10 +67,6 @@ void executeRequest() throws Exception {
assertThat(clientResponse.getStatusCode()).isEqualTo(200);
assertThat(clientResponse.getResponseBody()).isEqualTo("hello");
- verify(request, times(1)).header(headerKeyCaptor.capture(), headerValueCaptor.capture());
- assertThat(headerKeyCaptor.getValue()).isEqualTo(HEADER_KEY_CLIENT_TYPE);
- assertThat(headerValueCaptor.getValue()).isEqualTo(JETTY_REACTIVE_HTTP_CLIENT.getValue());
-
verify(request, times(1)).method(httpMethodCaptor.capture());
assertThat(httpMethodCaptor.getValue()).isEqualTo(HttpMethod.GET);
diff --git a/pom.xml b/pom.xml
index f200545..f5bc9e8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,9 +21,11 @@
2.0.0
1.8.1
8.3.5
- 2.7.18
- 1.7.33
+ 3.3.1
+ 2.0.13
+ 1.5.6
4.5.13
+ 5.3.1
7.18.0
3.2.5
3.2.5
@@ -33,7 +35,8 @@
2.16.1
3.2.0
4.12.0
- 1.1.16
+ 4.0.5
+ 12.0.11
1.19.4
3.1.6
3.6.3
@@ -54,15 +57,15 @@
11.8
1.6.0
2.3.11
- 3.285.1
+ 5.25.0.0
4.2.4
1.3.2
3.0.1
2.0.0
2.0.1
2.1.1
- 4.1.99.Final
- 2.0.62.Final
+ 4.1.108.Final
+ 2.0.65.Final
2.10.0
3.5.4
4.2.1
@@ -71,7 +74,7 @@
5.10.2
5.12.0
3.25.3
- 2.7.8
+ 2.9.3
1.14.15
5.3.1
3.2.18
@@ -125,11 +128,21 @@
httpclient
${version.apache.httpclient}
+
+ org.apache.httpcomponents.client5
+ httpclient5
+ ${version.apache.httpclient5}
+
org.eclipse.jetty
jetty-reactive-httpclient
${version.jetty-reactive-httpclient}
+
+ org.eclipse.jetty
+ jetty-client
+ ${version.jetty}
+
org.glassfish.jersey.core
jersey-client
@@ -351,6 +364,41 @@
netty-handler
${version.netty-handler}
+
+ io.netty
+ netty-resolver-dns
+ ${version.netty-handler}
+
+
+ io.netty
+ netty-codec-http2
+ ${version.netty-handler}
+
+
+ io.netty
+ netty-codec-http
+ ${version.netty-handler}
+
+
+ io.netty
+ netty-codec-socks
+ ${version.netty-handler}
+
+
+ io.netty
+ netty-handler-proxy
+ ${version.netty-handler}
+
+
+ io.netty
+ netty-transport-native-epoll
+ ${version.netty-handler}
+
+
+ io.netty
+ netty-transport-native-kqueue
+ ${version.netty-handler}
+
io.netty
netty-tcnative
@@ -361,6 +409,11 @@
netty-tcnative-boringssl-static
${version.netty-tcnative}
+
+ io.netty
+ netty-tcnative-boringssl-static
+ ${version.netty-tcnative}
+
@@ -470,6 +523,11 @@
slf4j-simple
${version.slf4j}
+
+ ch.qos.logback
+ logback-classic
+ ${version.logback}
+