我的需求是把Response Body 提取并保存即可,但是原有的header不要做任何修改。
[Script]
myScript = type=http-response, pattern="已省略", requires-body=1, max-size=-1, timeout=15, debug=1, script-path=myScript.js
现在js文件中是这样写的
var origBody = $response.body;
$persistentStore.write(origBody,"foo.json");
let origHeader = $response.headers;
console.log(origHeader);
$done({});
理论上response应当是untouched
,但是实际上Script自动修改了header。
以下是log
18:20:28.064898 {"Connection":"close","Server":"Kestrel","Transfer-Encoding":"chunked","Date":"Sat, 08 Apr 2023 10:20:28 GMT","set-cookie":"省略"}
18:20:28.065161 [Script Completed]
实际的response header是
HTTP/1.1 200 OK
Connection: close
Server: Kestrel
Date: Sat, 08 Apr 2023 10:20:28 GMT
set-cookie: 省略
Content-Encoding: identity
Content-Length: 113
原有response header应为
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Server: Kestrel
Date: Sat, 08 Apr 2023 10:20:28 GMT
Set-Cookie: 省略
Content-Encoding: gzip
Vary: Accept-Encoding
Strict-Transport-Security: max-age=2592000
在下面提供对比图,方便查看
请教一下是否存在某种方法可以防止Headers被修改?
我仅尝试过在config中对script添加binary-body-mode=1
字段,但是似乎没有用。