com.jimuwd.xian.registry-proxy 1.0.75 → 1.0.76
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/dist/index.js +6 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -199,9 +199,8 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
resToDownstreamClient.writeHead(upstreamResponse.status, { "content-type": contentType }).end(JSON.stringify(data));
|
|
202
|
-
reqFromDownstreamClient.destroy();
|
|
203
202
|
}
|
|
204
|
-
else {
|
|
203
|
+
else if (contentType.includes('application/octet-stream')) {
|
|
205
204
|
// 二进制流处理
|
|
206
205
|
if (!upstreamResponse.body) {
|
|
207
206
|
logger.error(`Empty response body from upstream ${targetUrl}`);
|
|
@@ -237,7 +236,7 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
237
236
|
logger.info(`Upstream server ${targetUrl} response.body ended.`);
|
|
238
237
|
resToDownstreamClient.end();
|
|
239
238
|
})
|
|
240
|
-
// connection will be closed automatically when all chunk data is transferred.
|
|
239
|
+
// connection will be closed automatically when all chunk data is transferred (after stream ends).
|
|
241
240
|
.on('close', () => {
|
|
242
241
|
logger.info(`Upstream server ${targetUrl} closed connection.`);
|
|
243
242
|
})
|
|
@@ -249,6 +248,10 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
249
248
|
});
|
|
250
249
|
}
|
|
251
250
|
}
|
|
251
|
+
else {
|
|
252
|
+
logger.warn(`Unsupported response content-type from upstream ${targetUrl}`);
|
|
253
|
+
resToDownstreamClient.writeHead(upstreamResponse.status, { "content-type": contentType }).end(upstreamResponse.text());
|
|
254
|
+
}
|
|
252
255
|
}
|
|
253
256
|
catch (err) {
|
|
254
257
|
logger.error('Failed to write upstreamResponse:', err);
|