Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions internal/extproc/backendauth/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ func (a *awsHandler) Do(ctx context.Context, requestHeaders map[string]string, h
if err != nil {
return fmt.Errorf("cannot create request: %w", err)
}
// By setting the content length to -1, we can avoid the inclusion of the `Content-Length` header in the signature.
// https://github.com/aws/aws-sdk-go-v2/blob/755839b2eebb246c7eec79b65404aee105196d5b/aws/signer/v4/v4.go#L427-L431
//
// The reason why we want to avoid this is that the ExtProc filter will remove the content-length header
// from the request currently. Envoy will instead do "transfer-encoding: chunked" for the request body,
// which should be acceptable for AWS Bedrock or any modern HTTP service.
// https://github.com/envoyproxy/envoy/blob/60b2b5187cf99db79ecfc54675354997af4765ea/source/extensions/filters/http/ext_proc/processor_state.cc#L180-L183
req.ContentLength = -1

err = a.signer.SignHTTP(ctx, a.credentials, req,
hex.EncodeToString(payloadHash[:]), "bedrock", a.region, time.Now())
Expand Down
Loading