|
3939 | 3939 | return base.PubNubFile;
|
3940 | 3940 | },
|
3941 | 3941 | get version() {
|
3942 |
| - return '9.3.2'; |
| 3942 | + return '9.4.0'; |
3943 | 3943 | },
|
3944 | 3944 | getVersion() {
|
3945 | 3945 | return this.version;
|
|
4604 | 4604 | body = formData;
|
4605 | 4605 | }
|
4606 | 4606 | // Handle regular body payload (if passed).
|
4607 |
| - else if (req.body && (typeof req.body === 'string' || req.body instanceof ArrayBuffer)) |
4608 |
| - body = req.body; |
| 4607 | + else if (req.body && (typeof req.body === 'string' || req.body instanceof ArrayBuffer)) { |
| 4608 | + // Compressing body if browser has native support. |
| 4609 | + if (req.compressible && typeof CompressionStream !== 'undefined') { |
| 4610 | + const bodyStream = new ReadableStream({ |
| 4611 | + start(controller) { |
| 4612 | + controller.enqueue(typeof req.body === 'string' ? WebTransport.encoder.encode(req.body) : req.body); |
| 4613 | + controller.close(); |
| 4614 | + }, |
| 4615 | + }); |
| 4616 | + body = yield new Response(bodyStream.pipeThrough(new CompressionStream('deflate'))).arrayBuffer(); |
| 4617 | + } |
| 4618 | + else |
| 4619 | + body = req.body; |
| 4620 | + } |
4609 | 4621 | if (req.queryParameters && Object.keys(req.queryParameters).length !== 0)
|
4610 | 4622 | path = `${path}?${queryStringFromObject(req.queryParameters)}`;
|
4611 | 4623 | return {
|
|
4683 | 4695 | return fetch;
|
4684 | 4696 | }
|
4685 | 4697 | }
|
| 4698 | + /** |
| 4699 | + * Request body decoder. |
| 4700 | + * |
| 4701 | + * @internal |
| 4702 | + */ |
| 4703 | + WebTransport.encoder = new TextEncoder(); |
4686 | 4704 | /**
|
4687 | 4705 | * Service {@link ArrayBuffer} response decoder.
|
4688 | 4706 | *
|
|
6092 | 6110 | * @returns Request object which can be processed using platform-specific requirements.
|
6093 | 6111 | */
|
6094 | 6112 | request() {
|
6095 |
| - var _a, _b, _c, _d; |
| 6113 | + var _a, _b, _c, _d, _e, _f; |
6096 | 6114 | const request = {
|
6097 | 6115 | method: (_b = (_a = this.params) === null || _a === void 0 ? void 0 : _a.method) !== null && _b !== void 0 ? _b : TransportMethod.GET,
|
6098 | 6116 | path: this.path,
|
6099 | 6117 | queryParameters: this.queryParameters,
|
6100 | 6118 | cancellable: (_d = (_c = this.params) === null || _c === void 0 ? void 0 : _c.cancellable) !== null && _d !== void 0 ? _d : false,
|
| 6119 | + compressible: (_f = (_e = this.params) === null || _e === void 0 ? void 0 : _e.compressible) !== null && _f !== void 0 ? _f : false, |
6101 | 6120 | timeout: 10,
|
6102 | 6121 | identifier: this.requestIdentifier,
|
6103 | 6122 | };
|
|
6121 | 6140 | * @returns Key/value headers which should be used with request.
|
6122 | 6141 | */
|
6123 | 6142 | get headers() {
|
6124 |
| - return undefined; |
| 6143 | + var _a, _b; |
| 6144 | + return Object.assign({ 'Accept-Encoding': 'gzip, deflate' }, (((_b = (_a = this.params) === null || _a === void 0 ? void 0 : _a.compressible) !== null && _b !== void 0 ? _b : false) ? { 'Content-Encoding': 'deflate' } : {})); |
6125 | 6145 | }
|
6126 | 6146 | /**
|
6127 | 6147 | * Target REST API endpoint request path getter.
|
|
6595 | 6615 | });
|
6596 | 6616 | }
|
6597 | 6617 | get headers() {
|
6598 |
| - return { accept: 'text/javascript' }; |
| 6618 | + var _a; |
| 6619 | + return Object.assign(Object.assign({}, ((_a = super.headers) !== null && _a !== void 0 ? _a : {})), { accept: 'text/javascript' }); |
6599 | 6620 | }
|
6600 | 6621 | // --------------------------------------------------------
|
6601 | 6622 | // ------------------ Envelope parsing --------------------
|
|
8705 | 8726 | */
|
8706 | 8727 | constructor(parameters) {
|
8707 | 8728 | var _a;
|
8708 |
| - var _b; |
8709 |
| - super({ method: parameters.sendByPost ? TransportMethod.POST : TransportMethod.GET }); |
| 8729 | + const sendByPost = (_a = parameters.sendByPost) !== null && _a !== void 0 ? _a : SEND_BY_POST; |
| 8730 | + super({ method: sendByPost ? TransportMethod.POST : TransportMethod.GET, compressible: sendByPost }); |
8710 | 8731 | this.parameters = parameters;
|
8711 | 8732 | // Apply default request parameters.
|
8712 |
| - (_a = (_b = this.parameters).sendByPost) !== null && _a !== void 0 ? _a : (_b.sendByPost = SEND_BY_POST); |
| 8733 | + this.parameters.sendByPost = sendByPost; |
8713 | 8734 | }
|
8714 | 8735 | operation() {
|
8715 | 8736 | return RequestOperation$1.PNPublishOperation;
|
|
8749 | 8770 | return query;
|
8750 | 8771 | }
|
8751 | 8772 | get headers() {
|
| 8773 | + var _a; |
8752 | 8774 | if (!this.parameters.sendByPost)
|
8753 | 8775 | return undefined;
|
8754 |
| - return { 'Content-Type': 'application/json' }; |
| 8776 | + return Object.assign(Object.assign({}, ((_a = super.headers) !== null && _a !== void 0 ? _a : {})), { 'Content-Type': 'application/json' }); |
8755 | 8777 | }
|
8756 | 8778 | get body() {
|
8757 | 8779 | return this.prepareMessagePayload(this.parameters.message);
|
|
9734 | 9756 | return `/v1/message-actions/${subscribeKey}/channel/${encodeString(channel)}/message/${messageTimetoken}`;
|
9735 | 9757 | }
|
9736 | 9758 | get headers() {
|
9737 |
| - return { 'Content-Type': 'application/json' }; |
| 9759 | + var _a; |
| 9760 | + return Object.assign(Object.assign({}, ((_a = super.headers) !== null && _a !== void 0 ? _a : {})), { 'Content-Type': 'application/json' }); |
9738 | 9761 | }
|
9739 | 9762 | get body() {
|
9740 | 9763 | return JSON.stringify(this.parameters.action);
|
|
10028 | 10051 | return `/v1/files/${subscribeKey}/channels/${encodeString(channel)}/generate-upload-url`;
|
10029 | 10052 | }
|
10030 | 10053 | get headers() {
|
10031 |
| - return { 'Content-Type': 'application/json' }; |
| 10054 | + var _a; |
| 10055 | + return Object.assign(Object.assign({}, ((_a = super.headers) !== null && _a !== void 0 ? _a : {})), { 'Content-Type': 'application/json' }); |
10032 | 10056 | }
|
10033 | 10057 | get body() {
|
10034 | 10058 | return JSON.stringify({ name: this.parameters.name });
|
@@ -11860,11 +11884,12 @@
|
11860 | 11884 | return 'Data cannot be empty';
|
11861 | 11885 | }
|
11862 | 11886 | get headers() {
|
| 11887 | + var _a; |
11863 | 11888 | if (this.parameters.ifMatchesEtag) {
|
11864 |
| - return { 'If-Match': this.parameters.ifMatchesEtag }; |
| 11889 | + return Object.assign(Object.assign({}, ((_a = super.headers) !== null && _a !== void 0 ? _a : {})), { 'If-Match': this.parameters.ifMatchesEtag }); |
11865 | 11890 | }
|
11866 | 11891 | else {
|
11867 |
| - return undefined; |
| 11892 | + return super.headers; |
11868 | 11893 | }
|
11869 | 11894 | }
|
11870 | 11895 | get path() {
|
@@ -12232,11 +12257,12 @@
|
12232 | 12257 | return 'Data cannot be empty';
|
12233 | 12258 | }
|
12234 | 12259 | get headers() {
|
| 12260 | + var _a; |
12235 | 12261 | if (this.parameters.ifMatchesEtag) {
|
12236 |
| - return { 'If-Match': this.parameters.ifMatchesEtag }; |
| 12262 | + return Object.assign(Object.assign({}, ((_a = super.headers) !== null && _a !== void 0 ? _a : {})), { 'If-Match': this.parameters.ifMatchesEtag }); |
12237 | 12263 | }
|
12238 | 12264 | else {
|
12239 |
| - return undefined; |
| 12265 | + return super.headers; |
12240 | 12266 | }
|
12241 | 12267 | }
|
12242 | 12268 | get path() {
|
|
0 commit comments