@softchef/cdk-iot-device-management
Version:
IoT device management is composed of things, thing types, thing groups, jobs, files API services. The constructs can be used independently, that are based on full-managed service to create an API Gateway & Lambda function.
24 lines (23 loc) • 615 B
JavaScript
import { Readable } from "stream";
export function writeRequestBody(httpRequest, request) {
var expect = request.headers["Expect"] || request.headers["expect"];
if (expect === "100-continue") {
httpRequest.on("continue", function () {
writeBody(httpRequest, request.body);
});
}
else {
writeBody(httpRequest, request.body);
}
}
function writeBody(httpRequest, body) {
if (body instanceof Readable) {
body.pipe(httpRequest);
}
else if (body) {
httpRequest.end(Buffer.from(body));
}
else {
httpRequest.end();
}
}