mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(sns): deliver to HTTP endpoints over HTTP/1.1 (#7414)
The SNS HttpClient used the JDK default version, HTTP_2, so every http:// delivery carried an h2c upgrade offer (Connection: Upgrade, Upgrade: h2c), which AWS SNS never sends. Servers that accept the upgrade read an empty request body. Pin the client to HTTP/1.1, as HttpProxyInvoker already does. Closes #7426
This commit is contained in:
1 parent
dddc0b85cb
commit
8c252ef0de
2 files changed
+10
-1
No files matched your search
@@ -346,7 +346,11 @@ public class SnsService implements Resettable, ResourceProvider {
|
||||
this.firehoseService = firehoseService;
|
||||
this.baseUrl = baseUrl;
|
||||
this.objectMapper = objectMapper;
|
||||
this.httpClient = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(5)).build();
|
||||
// Pin to HTTP/1.1 like AWS SNS: the default HTTP_2 sends an h2c upgrade to http:// endpoints.
|
||||
this.httpClient = HttpClient.newBuilder()
|
||||
.version(HttpClient.Version.HTTP_1_1)
|
||||
.connectTimeout(Duration.ofSeconds(5))
|
||||
.build();
|
||||
this.messageSigner = messageSigner;
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -159,6 +159,9 @@ class SnsHttpDeliveryIntegrationTest {
|
||||
assertEquals(1, receivedRequests.size());
|
||||
ReceivedRequest confirmReq = receivedRequests.get(0);
|
||||
assertEquals("SubscriptionConfirmation", confirmReq.headers().get("X-amz-sns-message-type").get(0));
|
||||
// AWS SNS posts plain HTTP/1.1, with no h2c upgrade offer.
|
||||
assertNull(firstHeader(confirmReq.headers(), "Upgrade"));
|
||||
assertNull(firstHeader(confirmReq.headers(), "HTTP2-Settings"));
|
||||
|
||||
// Confirm the subscription
|
||||
confirmSubscription(confirmReq);
|
||||
@@ -192,6 +195,8 @@ class SnsHttpDeliveryIntegrationTest {
|
||||
assertEquals(topicArn, req.headers().get("X-amz-sns-topic-arn").get(0));
|
||||
assertNotNull(req.headers().get("X-amz-sns-message-id"));
|
||||
assertNotNull(req.headers().get("X-amz-sns-subscription-arn"));
|
||||
assertNull(firstHeader(req.headers(), "Upgrade"));
|
||||
assertNull(firstHeader(req.headers(), "HTTP2-Settings"));
|
||||
|
||||
// Verify body is a proper SNS notification envelope
|
||||
JsonNode envelope = objectMapper.readTree(req.body());
|
||||
|
||||
Reference in new issue
Block a user