@controlium/utils 1.0.2-alpha.4 → 1.0.2-alpha.5
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.
|
@@ -111,10 +111,12 @@ export class APIUtils {
|
|
|
111
111
|
dispatcher,
|
|
112
112
|
});
|
|
113
113
|
const responseBody = await fetchResponse.text();
|
|
114
|
-
|
|
114
|
+
const responseHeaders = Object.fromEntries(fetchResponse.headers.entries());
|
|
115
|
+
this.doResponseLogging(fetchResponse.status, fetchResponse.statusText, responseHeaders, responseBody);
|
|
115
116
|
return {
|
|
116
117
|
status: fetchResponse.status,
|
|
117
118
|
statusMessage: fetchResponse.statusText,
|
|
119
|
+
headers: responseHeaders,
|
|
118
120
|
body: responseBody,
|
|
119
121
|
};
|
|
120
122
|
}
|
|
@@ -197,9 +199,21 @@ export class APIUtils {
|
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
201
|
}
|
|
200
|
-
static doResponseLogging(status, statusText, body) {
|
|
202
|
+
static doResponseLogging(status, statusText, headers, body) {
|
|
201
203
|
Log.writeLine(LogLevels.FrameworkInformation, 'HTTP Response:-');
|
|
202
204
|
Log.writeLine(LogLevels.FrameworkInformation, ` Status [${status}] - [${statusText}]`);
|
|
205
|
+
Log.writeLine(LogLevels.FrameworkInformation, ' Headers;');
|
|
206
|
+
const headerEntries = Object.entries(headers);
|
|
207
|
+
if (headerEntries.length === 0) {
|
|
208
|
+
Log.writeLine(LogLevels.FrameworkInformation, ' <No headers!>');
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
let headersStr = '';
|
|
212
|
+
headerEntries.forEach(([key, value]) => {
|
|
213
|
+
headersStr += `${headersStr === '' ? '' : '\n'} "${key}": "${value}"`;
|
|
214
|
+
});
|
|
215
|
+
Log.writeLine(LogLevels.FrameworkInformation, headersStr);
|
|
216
|
+
}
|
|
203
217
|
Log.writeLine(LogLevels.FrameworkInformation, ' Body;');
|
|
204
218
|
let indented = '';
|
|
205
219
|
if (body) {
|