@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.
28 lines (27 loc) • 771 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeRequestBody = void 0;
const stream_1 = require("stream");
function writeRequestBody(httpRequest, request) {
const expect = request.headers["Expect"] || request.headers["expect"];
if (expect === "100-continue") {
httpRequest.on("continue", () => {
writeBody(httpRequest, request.body);
});
}
else {
writeBody(httpRequest, request.body);
}
}
exports.writeRequestBody = writeRequestBody;
function writeBody(httpRequest, body) {
if (body instanceof stream_1.Readable) {
body.pipe(httpRequest);
}
else if (body) {
httpRequest.end(Buffer.from(body));
}
else {
httpRequest.end();
}
}