You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SigV4: Add host header only when not already provided (#5608)
* SigV4: Add host header only when not already provided
* http-client: respect user host header
---------
Co-authored-by: Vladimir Sudilovsky <[email protected]>
Co-authored-by: Daniel Cullen <[email protected]>
Copy file name to clipboardExpand all lines: core/http-auth-aws/src/main/java/software/amazon/awssdk/http/auth/aws/internal/signer/util/SignerUtils.java
+7
Original file line number
Diff line number
Diff line change
@@ -171,6 +171,13 @@ public static void addHostHeader(SdkHttpRequest.Builder requestBuilder) {
171
171
// AWS4 requires that we sign the Host header, so we
172
172
// have to have it in the request by the time we sign.
173
173
174
+
// If the SdkHttpRequest has an associated Host header
175
+
// already set, prefer to use that.
176
+
177
+
if (requestBuilder.headers().get(SignerConstant.HOST) != null) {
178
+
return;
179
+
}
180
+
174
181
Stringhost = requestBuilder.host();
175
182
if (!SdkHttpUtils.isUsingStandardPort(requestBuilder.protocol(), requestBuilder.port())) {
Copy file name to clipboardExpand all lines: core/http-auth-aws/src/test/java/software/amazon/awssdk/http/auth/aws/internal/signer/V4RequestSignerTest.java
Copy file name to clipboardExpand all lines: http-clients/apache-client/src/main/java/software/amazon/awssdk/http/apache/internal/impl/ApacheHttpRequestFactory.java
Copy file name to clipboardExpand all lines: http-clients/apache-client/src/test/java/software/amazon/awssdk/http/apache/internal/impl/ApacheHttpRequestFactoryTest.java
+40
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,46 @@ public void createSetsHostHeaderByDefault() {
Copy file name to clipboardExpand all lines: http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/RequestAdapter.java
Copy file name to clipboardExpand all lines: http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/RequestAdapterTest.java
+28
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,34 @@ public void adapt_hostHeaderSet() {
0 commit comments