pjfanning opened a new pull request, #1546:
URL: https://github.com/apache/pekko-connectors/pull/1546
With AWS SDK 2.42.x+, `SdkHttpContentPublisher.contentLength()` may return
`None` for some request types (e.g. `UploadPart`). When that happens,
`PekkoHttpClient` builds an `HttpEntity` with unknown length, causing Pekko
HTTP to use `Transfer-Encoding: chunked` — which mismatches the signed
`Content-Length` header and triggers an S3 signature verification failure.
Maybe a fix for #1543
## Changes
- **`convertHeaders`**: return type changed from `(Option[HttpHeader],
Seq[HttpHeader])` to `(Option[HttpHeader], Seq[HttpHeader], Option[Long])` —
the SDK's `Content-Length` value is now captured before being stripped from the
headers map.
- **`toPekkoRequest`**: passes the extracted `sdkContentLength` through to
entity construction.
- **`entityForMethodAndContentType`**: new `sdkContentLength: Option[Long] =
None` parameter; prefers the SDK-supplied length over
`contentPublisher.contentLength()`, falling back to the publisher only when
neither is set.
```scala
// Before: publisher returning None → chunked entity → SigV4 mismatch
case None => HttpEntity(contentType,
Source.fromPublisher(contentPublisher).map(ByteString(_)))
// After: SDK header Content-Length is captured and used first
val contentLength: Option[Long] =
sdkContentLength.orElse(contentPublisher.contentLength().toScala.map(_.toLong))
contentLength match {
case Some(length) => HttpEntity(contentType, length,
Source.fromPublisher(contentPublisher).map(ByteString(_)))
case None => HttpEntity(contentType,
Source.fromPublisher(contentPublisher).map(ByteString(_)))
}
```
The AWS SDK always sets `Content-Length` on non-chunked-signing requests, so
recovering it from the request headers before `convertHeaders` strips it is
sufficient to fix all known affected paths.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]