Skip to content

Commit 9faed77

Browse files
authoredSep 22, 2021
Allow types for HttpRequest.body to be either a string or a buffer (#3509)
* test httpRequest.body as string or buffer * request body may be a string or a buffer Looking at the source, it seems clear that the body of a request may be either a string or a buffer. https://github.com/aws/aws-sdk-js/blob/14e9bf0abab009e2f34f11623949375b7bd07d2a/lib/http/node.js#L115-L142 This commit fixes the types accordingly. * add changelog json diff
1 parent b6b065c commit 9faed77

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "bugfix",
3+
"category": "HttpRequest",
4+
"description": "Allows request body to be either a string or a buffer"
5+
}

‎lib/http_request.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class HttpRequest {
1818
/**
1919
* The request body payload.
2020
*/
21-
body: string;
21+
body: string | Buffer;
2222
/**
2323
* The endpoint for the request.
2424
*/

‎ts/request.ts

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ request.on('error', function(err, response) {
1919

2020
});
2121
request.on('build', function(request) {
22+
// test body as string
23+
request.httpRequest.body = 'Hello'
24+
// test body as buffer
25+
request.httpRequest.body = Buffer.from('Hello')
26+
2227
console.log(request.httpRequest.method);
2328
});
2429
request.on('complete', function(response) {

0 commit comments

Comments
 (0)
Please sign in to comment.