com.jimuwd.xian.registry-proxy 1.0.89 → 1.0.91

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 +6 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -186,6 +186,7 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
186
186
  if (contentType.includes('application/json')) { // JSON 处理逻辑
187
187
  const data = await upstreamResponse.json();
188
188
  if (data.versions) { // 处理node依赖包元数据
189
+ logger.info("Write package meta data application/json response from upstream to downstream", targetUrl);
189
190
  const host = reqFromDownstreamClient.headers.host || `localhost:${proxyPort}`;
190
191
  const baseUrl = `${proxyInfo.https ? 'https' : 'http'}://${host}${proxyInfo.basePath === '/' ? '' : proxyInfo.basePath}`;
191
192
  for (const versionKey in data.versions) {
@@ -198,12 +199,16 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
198
199
  }
199
200
  }
200
201
  }
202
+ else {
203
+ logger.info("Write none meta data application/json response from upstream to downstream", targetUrl);
204
+ }
201
205
  const bodyData = JSON.stringify(data);
202
206
  const safeHeaders = { 'content-type': contentType, 'content-length': Buffer.byteLength(bodyData) };
203
207
  logger.info(`Response to downstream client headers`, JSON.stringify(safeHeaders), targetUrl);
204
208
  resToDownstreamClient.writeHead(upstreamResponse.status, { 'content-type': 'application/json' }).end(bodyData);
205
209
  }
206
210
  else if (contentType.includes('application/octet-stream')) { // 二进制流处理
211
+ logger.info("Write application/octet-stream response from upstream to downstream", targetUrl);
207
212
  // 准备通用响应头信息
208
213
  const safeHeaders = {};
209
214
  // 复制所有可能需要的头信息(不包含安全相关的敏感头信息,如access-control-allow-origin、set-cookie、server、strict-transport-security等,这意味着代理服务器向下游客户端屏蔽了这些认证等安全数据)
@@ -261,7 +266,7 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
261
266
  }
262
267
  }
263
268
  else {
264
- logger.warn(`Unsupported response content-type from upstream ${targetUrl}`);
269
+ logger.warn(`Write unsupported content-type=${contentType} response from upstream to downstream ${targetUrl}`);
265
270
  const bodyData = await upstreamResponse.text();
266
271
  const safeHeaders = { 'content-type': contentType, 'content-length': Buffer.byteLength(bodyData) };
267
272
  logger.info(`Response to downstream client headers`, JSON.stringify(safeHeaders), targetUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.0.89",
3
+ "version": "1.0.91",
4
4
  "description": "A lightweight npm registry proxy with fallback support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",