@celonis/content-cli 1.1.2 → 1.1.3
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/core/http/http-client.js +28 -12
- package/package.json +1 -1
package/core/http/http-client.js
CHANGED
|
@@ -150,20 +150,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
150
150
|
return new Promise((resolve, reject) => {
|
|
151
151
|
this.axios.post(this.resolveUrl(url), null, {
|
|
152
152
|
headers: this.buildHeaders(),
|
|
153
|
-
responseType: "stream"
|
|
153
|
+
responseType: "stream",
|
|
154
|
+
validateStatus: () => true, // Accept all status codes, handle manually
|
|
154
155
|
}).then(response => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
if (this.checkBadRequest(response.status)) {
|
|
157
|
+
// For error responses, collect as text for readable error messages
|
|
158
|
+
let errorData = '';
|
|
159
|
+
response.data.setEncoding('utf8');
|
|
160
|
+
response.data.on('data', (chunk) => {
|
|
161
|
+
errorData += chunk;
|
|
162
|
+
});
|
|
163
|
+
response.data.on('end', () => {
|
|
164
|
+
this.handleBadRequest(response.status, errorData, reject);
|
|
165
|
+
});
|
|
166
|
+
response.data.on('error', (err) => {
|
|
167
|
+
reject(`Error reading error response: ${err.message}`);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
// For successful responses, collect as binary for file download
|
|
172
|
+
const data = [];
|
|
173
|
+
response.data.on("data", (chunk) => {
|
|
174
|
+
data.push(chunk);
|
|
175
|
+
});
|
|
176
|
+
response.data.on("end", () => {
|
|
164
177
|
this.handleResponseStreamData(Buffer.concat(data), resolve, reject);
|
|
165
|
-
}
|
|
166
|
-
|
|
178
|
+
});
|
|
179
|
+
response.data.on('error', (err) => {
|
|
180
|
+
reject(`Error reading file data: ${err.message}`);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
167
183
|
}).catch(err => {
|
|
168
184
|
this.handleError(err, resolve, reject);
|
|
169
185
|
});
|