"body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>NotImplemented</Code><Message>A header you provided implies functionality that is not implemented</Message><Header>Transfer-Encoding</Header><RequestId>XXXXX</RequestId><HostId>XXXX=</HostId></Error>",
After reading about this on different sites the Content-Length header should be set to avoid chunked transfer-encoding. Since the http-lib doesnt do that itself I tried to add the header “Content-Length” but it’s restricted:
Looks like this is related to the use of ofInputStream() BodyPublisher used in the http-client.
BodyPublishers.ofInputStream() creates a RequestPublishers.InputStreamPublisher which always implements contentLength() method as “return -1;”. This means the content length of the request is unknown. When the HttpClient encounters a request body of unknown content length it defaults to chunked encoding, because this encoding doesnot require the content length to be transfered. S3 on the other hand does not allow chunked encoding to be used to upload files.
If it was possible to use the BodyPublishers.ofByteArray() instead, the request would be able to set the content length, but I am not sure if this is easy to do with how the http-client is designed today.