com.jimuwd.xian.registry-proxy 1.0.93 → 1.0.95

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -204,11 +204,14 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
204
204
  logger.info("Write none meta data application/json response from upstream to downstream", targetUrl);
205
205
  }
206
206
  const bodyData = JSON.stringify(data);
207
- const safeHeaders = { 'content-type': contentType, 'content-length': Buffer.byteLength(bodyData) };
208
- // resToDownstreamClient.removeHeader('Transfer-Encoding');
209
- // resToDownstreamClient.setHeader('content-type','application/json');
210
- logger.info(`Response to downstream client headers`, JSON.stringify(safeHeaders), targetUrl);
211
- resToDownstreamClient.writeHead(upstreamResponse.status, safeHeaders).end(bodyData);
207
+ resToDownstreamClient.removeHeader('Transfer-Encoding');
208
+ // 默认是 connection: keep-alive 和 keep-alive: timeout=5,这里直接给它咔嚓掉
209
+ resToDownstreamClient.setHeader('Connection', 'close');
210
+ resToDownstreamClient.removeHeader('Keep-Alive');
211
+ resToDownstreamClient.setHeader('content-type', 'application/json');
212
+ resToDownstreamClient.setHeader('content-length', Buffer.byteLength(bodyData));
213
+ logger.info(`Response to downstream client headers`, JSON.stringify(resToDownstreamClient.getHeaders()), targetUrl);
214
+ resToDownstreamClient.writeHead(upstreamResponse.status).end(bodyData);
212
215
  }
213
216
  else if (contentType.includes('application/octet-stream')) { // 二进制流处理
214
217
  logger.info("Write application/octet-stream response from upstream to downstream", targetUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.0.93",
3
+ "version": "1.0.95",
4
4
  "description": "A lightweight npm registry proxy with fallback support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",