Skip to content

Commit 1a271f1

Browse files
committed
A better way to select fallback http protocol
1 parent 9f467f4 commit 1a271f1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

driver/src/main/java/oracle/nosql/driver/httpclient/HttpClient.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ private HttpClient(String host,
233233
httpProtocols :
234234
new ArrayList<>(Arrays.asList(ApplicationProtocolNames.HTTP_2, ApplicationProtocolNames.HTTP_1_1));
235235

236-
this.httpFallbackProtocol = this.httpProtocols.get(this.httpProtocols.size() - 1);
236+
// If Http1.1 is in the httpProtocols list, we prefer use it as the fallback
237+
// Else we use the last protocol in the httpProtocols list.
238+
this.httpFallbackProtocol = this.httpProtocols.contains(ApplicationProtocolNames.HTTP_1_1) ?
239+
ApplicationProtocolNames.HTTP_1_1 : this.httpProtocols.get(this.httpProtocols.size() - 1);
237240

238241
this.maxContentLength = (maxContentLength == 0 ?
239242
DEFAULT_MAX_CONTENT_LENGTH : maxContentLength);

0 commit comments

Comments
 (0)