Skip to content

Commit

Permalink
add documentation about setting a specific HTTP protocol version
Browse files Browse the repository at this point in the history
  • Loading branch information
jenschude committed Jan 22, 2025
1 parent 7b557f3 commit 40b2fa0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions commercetools/internal-docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ dependencies {
implementation project(":commercetools:commercetools-http-client")
implementation project(":commercetools:commercetools-okhttp-client4")
implementation project(":commercetools:commercetools-apachehttp-client")
implementation project(":commercetools:commercetools-reactornetty-client")
implementation project(":commercetools:commercetools-sdk-compat-v1")
implementation project(":commercetools:commercetools-graphql-api")
implementation project(":commercetools:commercetools-monitoring-newrelic")
implementation project(":commercetools:commercetools-monitoring-datadog")

testImplementation ctsdkv1.client version ctsdkv1.version
implementation ctsdkv1.models version ctsdkv1.version
testImplementation project(":commercetools:commercetools-javanet-client")

testImplementation commons.io version commons.io_version

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
* <p>The third option is to use the timeout functionality of the futures</p>
*
* {@include.example example.ExamplesTest#timeoutFuture()}
*
* <h3 id=http-version>HTTP protocol version</h3>
*
* <p>In case it's needed so specify a specific HTTP protocol version this can be done through the HTTP client package itself.</p>
*
* {@include.example example.ExamplesTest#httpVersion()}
*
* <p>The AsyncHttpClient and OkHttp packages use HTTP1.1 by default.</p>
*/
public class ClientTuning {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.http.HttpClient;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -35,6 +36,8 @@
import com.commercetools.api.models.project.Project;
import com.commercetools.api.models.tax_category.TaxCategoryPagedQueryResponse;
import com.commercetools.http.apachehttp.CtApacheHttpClient;
import com.commercetools.http.javanet.CtJavaNetHttpClient;
import com.commercetools.http.netty.CtNettyHttpClient;
import com.commercetools.http.okhttp4.CtOkHttp4Client;

import io.vrap.rmf.base.client.*;
Expand All @@ -43,13 +46,15 @@

import org.apache.commons.lang3.tuple.Pair;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.util.Timeout;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.event.Level;

import dev.failsafe.Failsafe;
import dev.failsafe.FailsafeExecutor;
import reactor.netty.http.HttpProtocol;

public class ExamplesTest {

Expand Down Expand Up @@ -623,4 +628,10 @@ public void mdcProjectApiRoot() {
ProjectApiRoot globalRoot = ProjectApiRoot.of("test");
ProjectApiRoot apiRoot = ProjectApiRoot.withContext(globalRoot, new MDCContext());
}

public void httpVersion() {
CtApacheHttpClient apacheHttpClient = new CtApacheHttpClient(HttpVersionPolicy.FORCE_HTTP_1);
CtNettyHttpClient nettyHttpClient = new CtNettyHttpClient(HttpProtocol.HTTP11);
CtJavaNetHttpClient javaNetHttpClient = new CtJavaNetHttpClient(HttpClient.Version.HTTP_1_1);
}
}

0 comments on commit 40b2fa0

Please sign in to comment.