@podium/client 4.5.22 → 5.0.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +196 -0
- package/README.md +1 -1
- package/dist/package.json +3 -0
- package/lib/client.js +63 -140
- package/lib/http-outgoing.js +70 -90
- package/lib/resolver.cache.js +16 -22
- package/lib/resolver.content.js +59 -61
- package/lib/resolver.fallback.js +45 -47
- package/lib/resolver.js +38 -49
- package/lib/resolver.manifest.js +50 -117
- package/lib/resource.js +45 -50
- package/lib/response.js +40 -37
- package/lib/state.js +42 -46
- package/lib/utils.js +3 -41
- package/package.json +21 -25
package/lib/http-outgoing.js
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const _maxAge = Symbol('podium:httpoutgoing:maxage');
|
|
24
|
-
const _status = Symbol('podium:httpoutgoing:status');
|
|
25
|
-
const _name = Symbol('podium:httpoutgoing:name');
|
|
26
|
-
const _uri = Symbol('podium:httpoutgoing:uri');
|
|
27
|
-
|
|
28
|
-
const PodletClientHttpOutgoing = class PodletClientHttpOutgoing extends PassThrough {
|
|
3
|
+
import { PassThrough } from 'stream';
|
|
4
|
+
import assert from 'assert';
|
|
5
|
+
|
|
6
|
+
export default class PodletClientHttpOutgoing extends PassThrough {
|
|
7
|
+
#rejectUnauthorized;
|
|
8
|
+
#killRecursions;
|
|
9
|
+
#killThreshold;
|
|
10
|
+
#redirectable;
|
|
11
|
+
#reqOptions;
|
|
12
|
+
#throwable;
|
|
13
|
+
#manifest;
|
|
14
|
+
#incoming;
|
|
15
|
+
#redirect;
|
|
16
|
+
#timeout;
|
|
17
|
+
#success;
|
|
18
|
+
#headers;
|
|
19
|
+
#maxAge;
|
|
20
|
+
#status;
|
|
21
|
+
#name;
|
|
22
|
+
#uri;
|
|
29
23
|
constructor(
|
|
30
24
|
{
|
|
31
25
|
rejectUnauthorized = true,
|
|
32
|
-
resolveCss = false,
|
|
33
|
-
resolveJs = false,
|
|
34
26
|
throwable = false,
|
|
35
27
|
redirectable = false,
|
|
36
28
|
retries = 4,
|
|
@@ -50,47 +42,44 @@ const PodletClientHttpOutgoing = class PodletClientHttpOutgoing extends PassThro
|
|
|
50
42
|
);
|
|
51
43
|
|
|
52
44
|
// If requests to https sites should reject on unsigned sertificates
|
|
53
|
-
this
|
|
45
|
+
this.#rejectUnauthorized = rejectUnauthorized;
|
|
54
46
|
|
|
55
47
|
// A HttpIncoming object
|
|
56
|
-
this
|
|
48
|
+
this.#incoming = incoming;
|
|
57
49
|
|
|
58
50
|
// Kill switch for breaking the recursive promise chain
|
|
59
51
|
// in case it is never able to completely resolve
|
|
60
|
-
this
|
|
61
|
-
this
|
|
52
|
+
this.#killRecursions = 0;
|
|
53
|
+
this.#killThreshold = retries;
|
|
62
54
|
|
|
63
55
|
// Options to be appended to the content request
|
|
64
|
-
this
|
|
56
|
+
this.#reqOptions = {
|
|
65
57
|
pathname: '',
|
|
66
58
|
query: {},
|
|
67
59
|
headers: {},
|
|
68
60
|
...reqOptions,
|
|
69
61
|
};
|
|
70
62
|
|
|
71
|
-
// If relative CSS/JS paths should be resolved into an absolute
|
|
72
|
-
// path based on the URI to the podlets manifest
|
|
73
|
-
this[_resolveCss] = resolveCss;
|
|
74
|
-
this[_resolveJs] = resolveJs;
|
|
75
|
-
|
|
76
63
|
// In the case of failure, should the resource throw or not
|
|
77
|
-
this
|
|
64
|
+
this.#throwable = throwable;
|
|
78
65
|
|
|
79
66
|
// Manifest which is either retrieved from the registry or
|
|
80
67
|
// remote podlet (in other words its not saved in registry yet)
|
|
81
|
-
this
|
|
68
|
+
this.#manifest = {
|
|
82
69
|
_fallback: '',
|
|
83
70
|
};
|
|
84
71
|
|
|
85
72
|
// How long before a request should time out
|
|
86
|
-
this
|
|
73
|
+
this.#timeout = timeout;
|
|
87
74
|
|
|
88
75
|
// Done indicator to break the promise chain
|
|
89
76
|
// Set to true when content is served
|
|
90
|
-
this
|
|
77
|
+
this.#success = false;
|
|
78
|
+
|
|
79
|
+
this.#headers = {};
|
|
91
80
|
|
|
92
81
|
// How long the manifest should be cached before refetched
|
|
93
|
-
this
|
|
82
|
+
this.#maxAge = maxAge;
|
|
94
83
|
|
|
95
84
|
// What status the manifest is in. This is used to tell what actions need to
|
|
96
85
|
// be performed throughout the resolving process to complete a request.
|
|
@@ -100,149 +89,140 @@ const PodletClientHttpOutgoing = class PodletClientHttpOutgoing extends PassThro
|
|
|
100
89
|
// "fresh" - the manifest has been fetched but is not stored in cache yet
|
|
101
90
|
// "cached" - the manifest was retrieved from cache
|
|
102
91
|
// "stale" - the manifest is outdated, a new manifest needs to be fetched
|
|
103
|
-
this
|
|
92
|
+
this.#status = 'empty';
|
|
104
93
|
|
|
105
94
|
// Name of the resource (name given to client)
|
|
106
|
-
this
|
|
95
|
+
this.#name = name;
|
|
107
96
|
|
|
108
97
|
// URI to manifest
|
|
109
|
-
this
|
|
98
|
+
this.#uri = uri;
|
|
110
99
|
|
|
111
100
|
// Whether the user can handle redirects manually.
|
|
112
|
-
this
|
|
101
|
+
this.#redirectable = redirectable;
|
|
113
102
|
|
|
114
103
|
// When redirectable is true, this object should be populated with redirect information
|
|
115
104
|
// such that a user can perform manual redirection
|
|
116
|
-
this
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
get [Symbol.toStringTag]() {
|
|
120
|
-
return 'PodletClientHttpOutgoing';
|
|
105
|
+
this.#redirect = null;
|
|
121
106
|
}
|
|
122
107
|
|
|
123
108
|
get rejectUnauthorized() {
|
|
124
|
-
return this
|
|
109
|
+
return this.#rejectUnauthorized;
|
|
125
110
|
}
|
|
126
111
|
|
|
127
112
|
get reqOptions() {
|
|
128
|
-
return this
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
get resolveCss() {
|
|
132
|
-
return this[_resolveCss];
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
get resolveJs() {
|
|
136
|
-
return this[_resolveJs];
|
|
113
|
+
return this.#reqOptions;
|
|
137
114
|
}
|
|
138
115
|
|
|
139
116
|
get throwable() {
|
|
140
|
-
return this
|
|
117
|
+
return this.#throwable;
|
|
141
118
|
}
|
|
142
119
|
|
|
143
120
|
get manifest() {
|
|
144
|
-
return this
|
|
121
|
+
return this.#manifest;
|
|
145
122
|
}
|
|
146
123
|
|
|
147
124
|
set manifest(obj) {
|
|
148
|
-
this
|
|
125
|
+
this.#manifest = obj;
|
|
149
126
|
}
|
|
150
127
|
|
|
151
128
|
get fallback() {
|
|
152
|
-
return this
|
|
129
|
+
return this.#manifest._fallback;
|
|
153
130
|
}
|
|
154
131
|
|
|
155
132
|
set fallback(value) {
|
|
156
|
-
this
|
|
133
|
+
this.#manifest._fallback = value;
|
|
157
134
|
}
|
|
158
135
|
|
|
159
136
|
get timeout() {
|
|
160
|
-
return this
|
|
137
|
+
return this.#timeout;
|
|
161
138
|
}
|
|
162
139
|
|
|
163
140
|
get success() {
|
|
164
|
-
return this
|
|
141
|
+
return this.#success;
|
|
165
142
|
}
|
|
166
143
|
|
|
167
144
|
set success(value) {
|
|
168
|
-
this
|
|
145
|
+
this.#success = value;
|
|
169
146
|
}
|
|
170
147
|
|
|
171
148
|
get context() {
|
|
172
|
-
return this
|
|
149
|
+
return this.#incoming.context;
|
|
173
150
|
}
|
|
174
151
|
|
|
175
152
|
get headers() {
|
|
176
|
-
return this
|
|
153
|
+
return this.#headers;
|
|
177
154
|
}
|
|
178
155
|
|
|
179
156
|
set headers(value) {
|
|
180
|
-
this
|
|
157
|
+
this.#headers = value;
|
|
181
158
|
}
|
|
182
159
|
|
|
183
160
|
get maxAge() {
|
|
184
|
-
return this
|
|
161
|
+
return this.#maxAge;
|
|
185
162
|
}
|
|
186
163
|
|
|
187
164
|
set maxAge(value) {
|
|
188
|
-
this
|
|
165
|
+
this.#maxAge = value;
|
|
189
166
|
}
|
|
190
167
|
|
|
191
168
|
get status() {
|
|
192
|
-
return this
|
|
169
|
+
return this.#status;
|
|
193
170
|
}
|
|
194
171
|
|
|
195
172
|
set status(value) {
|
|
196
|
-
this
|
|
173
|
+
this.#status = value;
|
|
197
174
|
}
|
|
198
175
|
|
|
199
176
|
get name() {
|
|
200
|
-
return this
|
|
177
|
+
return this.#name;
|
|
201
178
|
}
|
|
202
179
|
|
|
203
180
|
get manifestUri() {
|
|
204
|
-
return this
|
|
181
|
+
return this.#uri;
|
|
205
182
|
}
|
|
206
183
|
|
|
207
184
|
get fallbackUri() {
|
|
208
|
-
return this
|
|
185
|
+
return this.#manifest.fallback;
|
|
209
186
|
}
|
|
210
187
|
|
|
211
188
|
get contentUri() {
|
|
212
|
-
return this
|
|
189
|
+
return this.#manifest.content;
|
|
213
190
|
}
|
|
214
191
|
|
|
215
192
|
get kill() {
|
|
216
|
-
return this
|
|
193
|
+
return this.#killRecursions === this.#killThreshold;
|
|
217
194
|
}
|
|
218
195
|
|
|
219
196
|
get recursions() {
|
|
220
|
-
return this
|
|
197
|
+
return this.#killRecursions;
|
|
221
198
|
}
|
|
222
199
|
|
|
223
200
|
set recursions(value) {
|
|
224
|
-
this
|
|
201
|
+
this.#killRecursions = value;
|
|
225
202
|
}
|
|
226
203
|
|
|
227
204
|
get redirect() {
|
|
228
|
-
return this
|
|
205
|
+
return this.#redirect;
|
|
229
206
|
}
|
|
230
207
|
|
|
231
208
|
set redirect(value) {
|
|
232
|
-
this
|
|
209
|
+
this.#redirect = value;
|
|
233
210
|
}
|
|
234
211
|
|
|
235
212
|
get redirectable() {
|
|
236
|
-
return this
|
|
213
|
+
return this.#redirectable;
|
|
237
214
|
}
|
|
238
215
|
|
|
239
216
|
set redirectable(value) {
|
|
240
|
-
this
|
|
217
|
+
this.#redirectable = value;
|
|
241
218
|
}
|
|
242
219
|
|
|
243
220
|
pushFallback() {
|
|
244
|
-
this.push(this
|
|
221
|
+
this.push(this.#manifest._fallback);
|
|
245
222
|
this.push(null);
|
|
246
223
|
}
|
|
224
|
+
|
|
225
|
+
get [Symbol.toStringTag]() {
|
|
226
|
+
return 'PodletClientHttpOutgoing';
|
|
227
|
+
}
|
|
247
228
|
};
|
|
248
|
-
module.exports = PodletClientHttpOutgoing;
|
package/lib/resolver.cache.js
CHANGED
|
@@ -1,40 +1,30 @@
|
|
|
1
1
|
/* eslint-disable no-plusplus */
|
|
2
2
|
/* eslint-disable no-param-reassign */
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import clonedeep from 'lodash.clonedeep';
|
|
5
|
+
import abslog from 'abslog';
|
|
6
|
+
import assert from 'assert';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module.exports = class PodletClientCacheResolver {
|
|
8
|
+
export default class PodletClientCacheResolver {
|
|
9
|
+
#registry;
|
|
10
|
+
#log;
|
|
11
11
|
constructor(registry, options = {}) {
|
|
12
12
|
assert(
|
|
13
13
|
registry,
|
|
14
14
|
'you must pass a "registry" object to the PodletClientCacheResolver constructor',
|
|
15
15
|
);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
value: registry,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(this, 'log', {
|
|
22
|
-
value: abslog(options.logger),
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get [Symbol.toStringTag]() {
|
|
27
|
-
return 'PodletClientCacheResolver';
|
|
16
|
+
this.#registry = registry;
|
|
17
|
+
this.#log = abslog(options.logger);
|
|
28
18
|
}
|
|
29
19
|
|
|
30
20
|
load(outgoing) {
|
|
31
21
|
return new Promise(resolve => {
|
|
32
22
|
if (outgoing.status !== 'stale') {
|
|
33
|
-
const cached = this
|
|
23
|
+
const cached = this.#registry.get(outgoing.name);
|
|
34
24
|
if (cached) {
|
|
35
25
|
outgoing.manifest = clonedeep(cached);
|
|
36
26
|
outgoing.status = 'cached';
|
|
37
|
-
this
|
|
27
|
+
this.#log.debug(
|
|
38
28
|
`loaded manifest from cache - resource: ${outgoing.name}`,
|
|
39
29
|
);
|
|
40
30
|
}
|
|
@@ -46,12 +36,12 @@ module.exports = class PodletClientCacheResolver {
|
|
|
46
36
|
save(outgoing) {
|
|
47
37
|
return new Promise(resolve => {
|
|
48
38
|
if (outgoing.status === 'fresh') {
|
|
49
|
-
this
|
|
39
|
+
this.#registry.set(
|
|
50
40
|
outgoing.name,
|
|
51
41
|
outgoing.manifest,
|
|
52
42
|
outgoing.maxAge,
|
|
53
43
|
);
|
|
54
|
-
this
|
|
44
|
+
this.#log.debug(
|
|
55
45
|
`saved manifest to cache - resource: ${outgoing.name}`,
|
|
56
46
|
);
|
|
57
47
|
}
|
|
@@ -61,4 +51,8 @@ module.exports = class PodletClientCacheResolver {
|
|
|
61
51
|
resolve(outgoing);
|
|
62
52
|
});
|
|
63
53
|
}
|
|
54
|
+
|
|
55
|
+
get [Symbol.toStringTag]() {
|
|
56
|
+
return 'PodletClientCacheResolver';
|
|
57
|
+
}
|
|
64
58
|
};
|
package/lib/resolver.content.js
CHANGED
|
@@ -1,70 +1,64 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const putils = require('@podium/utils');
|
|
10
|
-
const { Boom, badGateway } = require('@hapi/boom');
|
|
11
|
-
const Response = require('./response');
|
|
12
|
-
const utils = require('./utils');
|
|
13
|
-
const pkg = require('../package.json');
|
|
3
|
+
import { pipeline } from 'stream';
|
|
4
|
+
import Metrics from '@metrics/client';
|
|
5
|
+
import request from 'request';
|
|
6
|
+
import abslog from 'abslog';
|
|
7
|
+
import * as putils from '@podium/utils';
|
|
8
|
+
import { Boom, badGateway } from '@hapi/boom';
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
value: abslog(options.logger),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
Object.defineProperty(this, 'clientName', {
|
|
24
|
-
enumerable: false,
|
|
25
|
-
value: options.clientName,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
Object.defineProperty(this, 'metrics', {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
value: new Metrics(),
|
|
31
|
-
});
|
|
10
|
+
import { join, dirname } from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
import fs from 'fs';
|
|
13
|
+
import * as utils from './utils.js';
|
|
14
|
+
import Response from './response.js';
|
|
32
15
|
|
|
33
|
-
|
|
34
|
-
value: options.httpsAgent,
|
|
35
|
-
});
|
|
16
|
+
const currentDirectory = dirname(fileURLToPath(import.meta.url));
|
|
36
17
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
18
|
+
const pkgJson = fs.readFileSync(join(currentDirectory, '../package.json'), 'utf-8');
|
|
19
|
+
const pkg = JSON.parse(pkgJson);
|
|
40
20
|
|
|
41
|
-
|
|
42
|
-
this.log.error(
|
|
43
|
-
'Error emitted by metric stream in @podium/client module',
|
|
44
|
-
error,
|
|
45
|
-
);
|
|
46
|
-
});
|
|
21
|
+
const UA_STRING = `${pkg.name} ${pkg.version}`;
|
|
47
22
|
|
|
48
|
-
|
|
23
|
+
export default class PodletClientContentResolver {
|
|
24
|
+
#log;
|
|
25
|
+
#metrics;
|
|
26
|
+
#histogram;
|
|
27
|
+
#httpAgent;
|
|
28
|
+
#httpsAgent;
|
|
29
|
+
constructor(options = {}) {
|
|
30
|
+
const name = options.clientName;
|
|
31
|
+
this.#log = abslog(options.logger);
|
|
32
|
+
this.#httpAgent = options.httpAgent;
|
|
33
|
+
this.#httpsAgent = options.httpsAgent;
|
|
34
|
+
this.#metrics = new Metrics();
|
|
35
|
+
this.#histogram = this.#metrics.histogram({
|
|
49
36
|
name: 'podium_client_resolver_content_resolve',
|
|
50
37
|
description: 'Time taken for success/failure of content request',
|
|
51
38
|
labels: {
|
|
52
|
-
name
|
|
39
|
+
name,
|
|
53
40
|
status: null,
|
|
54
41
|
podlet: null,
|
|
55
42
|
},
|
|
56
43
|
buckets: [0.001, 0.01, 0.1, 0.5, 1, 2, 10],
|
|
57
44
|
});
|
|
45
|
+
|
|
46
|
+
this.#metrics.on('error', error => {
|
|
47
|
+
this.#log.error(
|
|
48
|
+
'Error emitted by metric stream in @podium/client module',
|
|
49
|
+
error,
|
|
50
|
+
);
|
|
51
|
+
});
|
|
58
52
|
}
|
|
59
53
|
|
|
60
|
-
get
|
|
61
|
-
return
|
|
54
|
+
get metrics() {
|
|
55
|
+
return this.#metrics;
|
|
62
56
|
}
|
|
63
57
|
|
|
64
58
|
resolve(outgoing) {
|
|
65
59
|
return new Promise((resolve, reject) => {
|
|
66
60
|
if (outgoing.kill && outgoing.throwable) {
|
|
67
|
-
this
|
|
61
|
+
this.#log.warn(
|
|
68
62
|
`recursion detected - failed to resolve fetching of podlet ${outgoing.recursions} times - throwing - resource: ${outgoing.name} - url: ${outgoing.manifestUri}`,
|
|
69
63
|
);
|
|
70
64
|
reject(
|
|
@@ -76,7 +70,7 @@ module.exports = class PodletClientContentResolver {
|
|
|
76
70
|
}
|
|
77
71
|
|
|
78
72
|
if (outgoing.kill) {
|
|
79
|
-
this
|
|
73
|
+
this.#log.warn(
|
|
80
74
|
`recursion detected - failed to resolve fetching of podlet ${outgoing.recursions} times - serving fallback - resource: ${outgoing.name} - url: ${outgoing.manifestUri}`,
|
|
81
75
|
);
|
|
82
76
|
outgoing.success = true;
|
|
@@ -86,7 +80,7 @@ module.exports = class PodletClientContentResolver {
|
|
|
86
80
|
}
|
|
87
81
|
|
|
88
82
|
if (outgoing.status === 'empty' && outgoing.throwable) {
|
|
89
|
-
this
|
|
83
|
+
this.#log.warn(
|
|
90
84
|
`no manifest available - cannot read content - throwing - resource: ${outgoing.name} - url: ${outgoing.manifestUri}`,
|
|
91
85
|
);
|
|
92
86
|
reject(
|
|
@@ -96,7 +90,7 @@ module.exports = class PodletClientContentResolver {
|
|
|
96
90
|
}
|
|
97
91
|
|
|
98
92
|
if (outgoing.status === 'empty') {
|
|
99
|
-
this
|
|
93
|
+
this.#log.warn(
|
|
100
94
|
`no manifest available - cannot read content - serving fallback - resource: ${outgoing.name} - url: ${outgoing.manifestUri}`,
|
|
101
95
|
);
|
|
102
96
|
outgoing.success = true;
|
|
@@ -117,8 +111,8 @@ module.exports = class PodletClientContentResolver {
|
|
|
117
111
|
timeout: outgoing.timeout,
|
|
118
112
|
method: 'GET',
|
|
119
113
|
agent: outgoing.contentUri.startsWith('https://')
|
|
120
|
-
? this
|
|
121
|
-
: this
|
|
114
|
+
? this.#httpsAgent
|
|
115
|
+
: this.#httpAgent,
|
|
122
116
|
uri: putils.uriBuilder(
|
|
123
117
|
outgoing.reqOptions.pathname,
|
|
124
118
|
outgoing.contentUri,
|
|
@@ -131,13 +125,13 @@ module.exports = class PodletClientContentResolver {
|
|
|
131
125
|
reqOptions.followRedirect = false;
|
|
132
126
|
}
|
|
133
127
|
|
|
134
|
-
const timer = this
|
|
128
|
+
const timer = this.#histogram.timer({
|
|
135
129
|
labels: {
|
|
136
130
|
podlet: outgoing.name,
|
|
137
131
|
},
|
|
138
132
|
});
|
|
139
133
|
|
|
140
|
-
this
|
|
134
|
+
this.#log.debug(
|
|
141
135
|
`start reading content from remote resource - manifest version is ${outgoing.manifest.version} - resource: ${outgoing.name} - url: ${outgoing.contentUri}`,
|
|
142
136
|
);
|
|
143
137
|
|
|
@@ -153,7 +147,7 @@ module.exports = class PodletClientContentResolver {
|
|
|
153
147
|
},
|
|
154
148
|
});
|
|
155
149
|
|
|
156
|
-
this
|
|
150
|
+
this.#log.debug(
|
|
157
151
|
`remote resource responded with non 200 http status code for content - code: ${response.statusCode} - resource: ${outgoing.name} - url: ${outgoing.contentUri}`,
|
|
158
152
|
);
|
|
159
153
|
|
|
@@ -176,7 +170,7 @@ module.exports = class PodletClientContentResolver {
|
|
|
176
170
|
},
|
|
177
171
|
});
|
|
178
172
|
|
|
179
|
-
this
|
|
173
|
+
this.#log.warn(
|
|
180
174
|
`remote resource responded with non 200 http status code for content - code: ${response.statusCode} - resource: ${outgoing.name} - url: ${outgoing.contentUri}`,
|
|
181
175
|
);
|
|
182
176
|
outgoing.success = true;
|
|
@@ -192,7 +186,7 @@ module.exports = class PodletClientContentResolver {
|
|
|
192
186
|
? response.headers['podlet-version']
|
|
193
187
|
: undefined;
|
|
194
188
|
|
|
195
|
-
this
|
|
189
|
+
this.#log.debug(
|
|
196
190
|
`got head response from remote resource for content - header version is ${response.headers['podlet-version']} - resource: ${outgoing.name} - url: ${outgoing.contentUri}`,
|
|
197
191
|
);
|
|
198
192
|
|
|
@@ -206,7 +200,7 @@ module.exports = class PodletClientContentResolver {
|
|
|
206
200
|
},
|
|
207
201
|
});
|
|
208
202
|
|
|
209
|
-
this
|
|
203
|
+
this.#log.info(
|
|
210
204
|
`podlet version number in header differs from cached version number - aborting request to remote resource for content - resource: ${outgoing.name} - url: ${outgoing.contentUri}`,
|
|
211
205
|
);
|
|
212
206
|
r.abort();
|
|
@@ -234,9 +228,9 @@ module.exports = class PodletClientContentResolver {
|
|
|
234
228
|
}),
|
|
235
229
|
);
|
|
236
230
|
|
|
237
|
-
pipeline(r, outgoing, err => {
|
|
231
|
+
pipeline([r, outgoing], (err) => {
|
|
238
232
|
if (err) {
|
|
239
|
-
this
|
|
233
|
+
this.#log.warn('error while piping content stream', err);
|
|
240
234
|
}
|
|
241
235
|
});
|
|
242
236
|
});
|
|
@@ -250,7 +244,7 @@ module.exports = class PodletClientContentResolver {
|
|
|
250
244
|
},
|
|
251
245
|
});
|
|
252
246
|
|
|
253
|
-
this
|
|
247
|
+
this.#log.warn(
|
|
254
248
|
`could not create network connection to remote resource when trying to request content - resource: ${outgoing.name} - url: ${outgoing.contentUri}`,
|
|
255
249
|
);
|
|
256
250
|
reject(
|
|
@@ -268,7 +262,7 @@ module.exports = class PodletClientContentResolver {
|
|
|
268
262
|
},
|
|
269
263
|
});
|
|
270
264
|
|
|
271
|
-
this
|
|
265
|
+
this.#log.warn(
|
|
272
266
|
`could not create network connection to remote resource when trying to request content - resource: ${outgoing.name} - url: ${outgoing.contentUri}`,
|
|
273
267
|
);
|
|
274
268
|
|
|
@@ -285,7 +279,7 @@ module.exports = class PodletClientContentResolver {
|
|
|
285
279
|
},
|
|
286
280
|
});
|
|
287
281
|
|
|
288
|
-
this
|
|
282
|
+
this.#log.debug(
|
|
289
283
|
`successfully read content from remote resource - resource: ${outgoing.name} - url: ${outgoing.contentUri}`,
|
|
290
284
|
);
|
|
291
285
|
|
|
@@ -293,4 +287,8 @@ module.exports = class PodletClientContentResolver {
|
|
|
293
287
|
});
|
|
294
288
|
});
|
|
295
289
|
}
|
|
290
|
+
|
|
291
|
+
get [Symbol.toStringTag]() {
|
|
292
|
+
return 'PodletClientContentResolver';
|
|
293
|
+
}
|
|
296
294
|
};
|