botframework-streaming
Version:
Streaming library for the Microsoft Bot Framework
57 lines • 2.35 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpContent = exports.HttpContentStream = void 0;
/**
* @module botframework-streaming
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const protocol_base_1 = require("./utilities/protocol-base");
/**
* An attachment contained within a StreamingRequest's stream collection, which itself contains any form of media item.
*/
class HttpContentStream {
/**
* Initializes a new instance of the [HttpContentStream](xref:botframework-streaming.HttpContentStream) class.
*
* @param content The [HttpContent](xref:botframework-streaming.HttpContent) to assign to the [HttpContentStream](xref:botframework-streaming.HttpContentStream).
*/
constructor(content) {
var _a, _b, _c, _d, _e, _f;
this.content = content;
this.id = (0, protocol_base_1.generateGuid)();
this.description = {
id: this.id,
type: (_c = (_b = (_a = this.content) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : 'unknown',
length: (_f = (_e = (_d = this.content) === null || _d === void 0 ? void 0 : _d.headers) === null || _e === void 0 ? void 0 : _e.contentLength) !== null && _f !== void 0 ? _f : 0,
};
}
}
exports.HttpContentStream = HttpContentStream;
/**
* The HttpContent class that contains a [SubscribableStream](xref:botframework-streaming.SubscribableStream).
*/
class HttpContent {
/**
* Initializes a new instance of the [HttpContent](xref:botframework-streaming.HttpContent) class.
*
* @param headers The Streaming Http content header definition.
* @param stream The stream of buffered data.
*/
constructor(headers, stream) {
this.headers = headers;
this.stream = stream;
}
/**
* Gets the data contained within this [HttpContent](xref:botframework-streaming.HttpContent).
*
* @returns This [HttpContent's](xref:botframework-streaming.HttpContent) [SubscribableStream](xref:botframework-streaming.SubscribableStream) member.
*/
getStream() {
return this.stream;
}
}
exports.HttpContent = HttpContent;
//# sourceMappingURL=httpContentStream.js.map
;