From 5741bb2e10d65931f0f4e6168b134ce1498a0bc3 Mon Sep 17 00:00:00 2001 From: Onno Vos Date: Mon, 20 May 2024 16:17:55 +0200 Subject: [PATCH] Fix correct hostname for global endpoints --- lib/aws/request.ex | 4 ++++ test/aws/protocol_tests/json_post_test.exs | 1 + test/aws/protocol_tests/query_post_test.exs | 1 + test/aws/protocol_tests/rest_json_test.exs | 1 + test/aws/protocol_tests/rest_xml_test.exs | 1 + test/aws/request_test.exs | 1 + 6 files changed, 9 insertions(+) diff --git a/lib/aws/request.ex b/lib/aws/request.ex index f0ebc56f..93c6b08f 100644 --- a/lib/aws/request.ex +++ b/lib/aws/request.ex @@ -184,6 +184,7 @@ defmodule AWS.Request do endpoint: client.endpoint, service: metadata.signing_name, global?: metadata.global?, + hostname: metadata.hostname, endpoint_prefix: metadata.endpoint_prefix, account_id: :proplists.get_value("x-amz-account-id", headers, nil) } @@ -198,6 +199,9 @@ defmodule AWS.Request do %{endpoint: endpoint_fun} when is_function(endpoint_fun, 1) -> endpoint_fun.(build_options) + %{global?: true, hostname: hostname} when is_binary(hostname) -> + hostname + %{global?: true, endpoint: endpoint} -> endpoint = resolve_endpoint_sufix(endpoint) diff --git a/test/aws/protocol_tests/json_post_test.exs b/test/aws/protocol_tests/json_post_test.exs index 4533e5d6..850164b2 100644 --- a/test/aws/protocol_tests/json_post_test.exs +++ b/test/aws/protocol_tests/json_post_test.exs @@ -19,6 +19,7 @@ defmodule AWS.ProtocolTests.JSONPostTest do credential_scope: nil, endpoint_prefix: "foo", global?: false, + hostname: nil, protocol: "json", service_id: "Foo", signature_version: "v4", diff --git a/test/aws/protocol_tests/query_post_test.exs b/test/aws/protocol_tests/query_post_test.exs index 5a9c3738..18018681 100644 --- a/test/aws/protocol_tests/query_post_test.exs +++ b/test/aws/protocol_tests/query_post_test.exs @@ -19,6 +19,7 @@ defmodule AWS.ProtocolTests.QueryPostTest do credential_scope: nil, endpoint_prefix: "foo", global?: false, + hostname: nil, protocol: "query", service_id: "Foo", signature_version: "v4", diff --git a/test/aws/protocol_tests/rest_json_test.exs b/test/aws/protocol_tests/rest_json_test.exs index 6476a23c..991309f3 100644 --- a/test/aws/protocol_tests/rest_json_test.exs +++ b/test/aws/protocol_tests/rest_json_test.exs @@ -19,6 +19,7 @@ defmodule AWS.ProtocolTests.RestJSONTest do credential_scope: nil, endpoint_prefix: "foo", global?: false, + hostname: nil, protocol: "rest-json", service_id: "Foo", signature_version: "v4", diff --git a/test/aws/protocol_tests/rest_xml_test.exs b/test/aws/protocol_tests/rest_xml_test.exs index 2ea5b0c3..600b388e 100644 --- a/test/aws/protocol_tests/rest_xml_test.exs +++ b/test/aws/protocol_tests/rest_xml_test.exs @@ -19,6 +19,7 @@ defmodule AWS.ProtocolTests.RestXMLTest do credential_scope: nil, endpoint_prefix: "foo", global?: false, + hostname: nil, protocol: "rest-xml", service_id: "Foo", signature_version: "v4", diff --git a/test/aws/request_test.exs b/test/aws/request_test.exs index 4cac0207..5af76fd4 100644 --- a/test/aws/request_test.exs +++ b/test/aws/request_test.exs @@ -9,6 +9,7 @@ defmodule AWS.RequestTest do content_type: "application/x-amz-json-1.1", endpoint_prefix: "mobileanalytics", global?: false, + hostname: nil, protocol: "rest-json", signature_version: "v4", signing_name: "mobileanalytics"