Skip to content

Commit

Permalink
fix(request): finally
Browse files Browse the repository at this point in the history
Update request.dev.js
Update request.js
  • Loading branch information
VirgilClyne committed Nov 30, 2024
1 parent ca9d0c5 commit eca4102
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/request.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ Console.info(`FORMAT: ${FORMAT}`);
})()
.catch(e => Console.error(e))
.finally(() => {
switch ($response) {
default: // 有构造回复数据,返回构造的回复数据
//Console.debug(`finally`, `echo $response: ${JSON.stringify($response, null, 2)}`);
switch (typeof $response) {
case "object": // 有构造回复数据,返回构造的回复数据
//Console.debug("🚧 finally", `echo $response: ${JSON.stringify($response, null, 2)}`);
if ($response.headers?.["Content-Encoding"]) $response.headers["Content-Encoding"] = "identity";
if ($response.headers?.["content-encoding"]) $response.headers["content-encoding"] = "identity";
switch ($app) {
Expand All @@ -299,9 +299,12 @@ Console.info(`FORMAT: ${FORMAT}`);
break;
}
break;
case undefined: // 无构造回复数据,发送修改的请求数据
//Console.debug(`finally`, `$request: ${JSON.stringify($request, null, 2)}`);
case "undefined": // 无构造回复数据,发送修改的请求数据
//Console.debug("🚧 finally", `$request: ${JSON.stringify($request, null, 2)}`);
done($request);
break;
default:
Console.error(`不合法的 $response 类型: ${typeof $response}`);
break;
}
});
11 changes: 8 additions & 3 deletions src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ Console.info(`FORMAT: ${FORMAT}`);
})()
.catch(e => Console.error(e))
.finally(() => {
switch ($response) {
default: // 有构造回复数据,返回构造的回复数据
switch (typeof $response) {
case "object": // 有构造回复数据,返回构造的回复数据
//Console.debug("🚧 finally", `echo $response: ${JSON.stringify($response, null, 2)}`);
if ($response.headers?.["Content-Encoding"]) $response.headers["Content-Encoding"] = "identity";
if ($response.headers?.["content-encoding"]) $response.headers["content-encoding"] = "identity";
switch ($app) {
Expand All @@ -225,8 +226,12 @@ Console.info(`FORMAT: ${FORMAT}`);
break;
}
break;
case undefined: // 无构造回复数据,发送修改的请求数据
case "undefined": // 无构造回复数据,发送修改的请求数据
//Console.debug("🚧 finally", `$request: ${JSON.stringify($request, null, 2)}`);
done($request);
break;
default:
Console.error(`不合法的 $response 类型: ${typeof $response}`);
break;
}
});

0 comments on commit eca4102

Please sign in to comment.