Skip to content

Commit

Permalink
Use the Upgrade flow by default
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Dec 10, 2024
1 parent f63b0a2 commit c45caf5
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion client/rest/licenses/httpclient5-5.4.1.jar.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ce913081e592ee8eeee35c4e577d7dce13cba7a4
ce913081e592ee8eeee35c4e577d7dce13cba7a4
2 changes: 1 addition & 1 deletion client/rest/licenses/httpcore5-5.3.1.jar.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eaf64237945d7d0f301d48420e8bdb7f565a7b0e
eaf64237945d7d0f301d48420e8bdb7f565a7b0e
2 changes: 1 addition & 1 deletion client/rest/licenses/httpcore5-h2-5.3.1.jar.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
760c34db3ba41b0ffa07e956bc308d3a12356915
760c34db3ba41b0ffa07e956bc308d3a12356915
2 changes: 1 addition & 1 deletion client/rest/licenses/httpcore5-reactive-5.3.1.jar.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c4c0c3c7bbcb0db54aa7ddd39e34a835428c99c0
c4c0c3c7bbcb0db54aa7ddd39e34a835428c99c0
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,11 @@ private CloseableHttpAsyncClient createHttpClient() {
// default timeouts are all infinite
RequestConfig.Builder requestConfigBuilder = RequestConfig.custom()
.setConnectTimeout(Timeout.ofMilliseconds(DEFAULT_CONNECT_TIMEOUT_MILLIS))
.setResponseTimeout(Timeout.ofMilliseconds(DEFAULT_RESPONSE_TIMEOUT_MILLIS))
.setProtocolUpgradeEnabled(false);
.setResponseTimeout(Timeout.ofMilliseconds(DEFAULT_RESPONSE_TIMEOUT_MILLIS));
if (requestConfigCallback != null) {
requestConfigBuilder = requestConfigCallback.customizeRequestConfig(requestConfigBuilder);
}
RequestConfig requestConfig = requestConfigBuilder.build();
if (requestConfig.isProtocolUpgradeEnabled()) {
throw new IllegalArgumentException("protocol upgrade is not supported");
}

try {
final TlsStrategy tlsStrategy = ClientTlsStrategyBuilder.create()
.setSslContext(SSLContext.getDefault())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ public void testHeaders() throws Exception {
if (method.equals("HEAD") == false) {
standardHeaders.add("Content-length");
}
if (method.equals("HEAD") == true || method.equals("GET") == true || method.equals("OPTIONS") == true) {
standardHeaders.add("Upgrade");
}

final Header[] requestHeaders = RestClientTestUtil.randomHeaders(getRandom(), "Header");
final int statusCode = randomStatusCode(getRandom());
Request request = new Request(method, "/" + statusCode);
Expand All @@ -400,11 +404,15 @@ public void testHeaders() throws Exception {
assertEquals(method, esResponse.getRequestLine().getMethod());
assertEquals(statusCode, esResponse.getStatusLine().getStatusCode());
assertEquals(pathPrefix + "/" + statusCode, esResponse.getRequestLine().getUri());

assertHeaders(defaultHeaders, requestHeaders, esResponse.getHeaders(), standardHeaders);
final Set<String> removedHeaders = new HashSet<>();
for (final Header responseHeader : esResponse.getHeaders()) {
String name = responseHeader.getName();
if (name.startsWith("Header") == false) {
// Some headers could be returned multiple times in response, like Connection fe.
if (name.startsWith("Header") == false && removedHeaders.contains(name) == false) {
assertTrue("unknown header was returned " + name, standardHeaders.remove(name));
removedHeaders.add(name);
}
}
assertTrue("some expected standard headers weren't returned: " + standardHeaders, standardHeaders.isEmpty());
Expand Down
2 changes: 1 addition & 1 deletion client/sniffer/licenses/httpclient5-5.4.1.jar.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ce913081e592ee8eeee35c4e577d7dce13cba7a4
ce913081e592ee8eeee35c4e577d7dce13cba7a4
2 changes: 1 addition & 1 deletion client/sniffer/licenses/httpcore5-5.3.1.jar.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eaf64237945d7d0f301d48420e8bdb7f565a7b0e
eaf64237945d7d0f301d48420e8bdb7f565a7b0e

0 comments on commit c45caf5

Please sign in to comment.