com.jimuwd.xian.registry-proxy 1.0.80 → 1.0.82
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 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -168,11 +168,11 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
168
168
|
throw new Error("Only 2xx upstream response is supported");
|
|
169
169
|
try {
|
|
170
170
|
const contentType = upstreamResponse.headers.get('content-type') || 'application/octet-stream';
|
|
171
|
-
const connection = upstreamResponse.headers.get("connection") || 'keep-alive';
|
|
171
|
+
// const connection = upstreamResponse.headers.get("connection") || 'keep-alive';
|
|
172
172
|
// 准备通用头信息
|
|
173
|
-
const safeHeaders = { 'connection': connection
|
|
173
|
+
const safeHeaders = { /*'connection': connection,*/ 'content-type': contentType, };
|
|
174
174
|
// 复制所有可能需要的头信息
|
|
175
|
-
const headersToCopy = ['content-encoding', 'transfer-encoding',];
|
|
175
|
+
const headersToCopy = ['connection', 'content-encoding', 'transfer-encoding',];
|
|
176
176
|
headersToCopy.forEach(header => {
|
|
177
177
|
const value = upstreamResponse.headers.get(header);
|
|
178
178
|
if (value)
|
|
@@ -196,7 +196,7 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
196
196
|
}
|
|
197
197
|
const bodyData = JSON.stringify(data);
|
|
198
198
|
if (!safeHeaders["transfer-encoding"]) {
|
|
199
|
-
|
|
199
|
+
logger.info(`Transfer-Encoding header is absent, then set the content-length header, upstream url is ${targetUrl}`);
|
|
200
200
|
safeHeaders["content-length"] = bodyData.length;
|
|
201
201
|
}
|
|
202
202
|
resToDownstreamClient.writeHead(upstreamResponse.status, safeHeaders).end(bodyData);
|
|
@@ -253,7 +253,7 @@ async function writeResponseToDownstreamClient(registryInfo, targetUrl, resToDow
|
|
|
253
253
|
// if transfer-encoding header is absent, then set the content-length header.
|
|
254
254
|
safeHeaders["content-length"] = bodyData.length;
|
|
255
255
|
}
|
|
256
|
-
resToDownstreamClient.writeHead(upstreamResponse.status, safeHeaders).end();
|
|
256
|
+
resToDownstreamClient.writeHead(upstreamResponse.status, safeHeaders).end(bodyData);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
catch (err) {
|