Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request body should allow Buffer object #146

Open
aleclarson opened this issue Jun 18, 2022 · 1 comment
Open

Request body should allow Buffer object #146

aleclarson opened this issue Jun 18, 2022 · 1 comment

Comments

@aleclarson
Copy link

aleclarson commented Jun 18, 2022

…and it shouldn't assume UTF8 encoding.

Currently, when calculating the content hash, UTF8 encoding is assumed:

aws4/aws4.js

Lines 14 to 15 in a413aad

function hash(string, encoding) {
return crypto.createHash('sha256').update(string, 'utf8').digest(encoding)

@sspiff
Copy link

sspiff commented Aug 13, 2024

According to https://nodejs.org/api/crypto.html#hashupdatedata-inputencoding, hash.update() will ignore the given encoding ('utf8' here) when the given data (string here) is already a Buffer. So maybe it already admits body as a Buffer? Admittedly, I haven't tested this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants