com.jimuwd.xian.registry-proxy 1.0.102 → 1.0.104
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 +5 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -221,7 +221,10 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
221
221
|
resToDownstreamClient.removeHeader('content-type');
|
|
222
222
|
resToDownstreamClient.setHeader('content-type', contentType);
|
|
223
223
|
logger.info(`Response to downstream client headers`, JSON.stringify(resToDownstreamClient.getHeaders()), targetUrl);
|
|
224
|
-
|
|
224
|
+
// 不再writeHead()而是设置状态码,然后执行pipe操作
|
|
225
|
+
resToDownstreamClient.statusCode = upstreamResponse.status;
|
|
226
|
+
resToDownstreamClient.statusMessage = upstreamResponse.statusText;
|
|
227
|
+
// resToDownstreamClient.writeHead(upstreamResponse.status);
|
|
225
228
|
// stop pipe when req from client is closed accidentally.
|
|
226
229
|
const cleanup = () => {
|
|
227
230
|
reqFromDownstreamClient.off('close', cleanup);
|
|
@@ -239,7 +242,7 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
239
242
|
resToDownstreamClient.on('close', cleanup0);
|
|
240
243
|
// write back body data (chunked probably)
|
|
241
244
|
// pipe upstream body to downstream client
|
|
242
|
-
upstreamResponse.body.pipe(resToDownstreamClient, { end:
|
|
245
|
+
upstreamResponse.body.pipe(resToDownstreamClient, { end: true });
|
|
243
246
|
upstreamResponse.body
|
|
244
247
|
.on('data', (chunk) => logger.info(`Chunk transferred from ${targetUrl} to downstream client size=${chunk.length}`))
|
|
245
248
|
.on('end', () => {
|