看起来 MarkLogic 服务端 JavaScript 中的 xdmp.http*
函数(xdmp.httpGet
、xdmp.httpPost
等)不支持响应头中的多个 Set-Cookie
-- 只返回其中一个 cookie。
xdmp.httpGet('https://httpbin.org/response-headers?Set-Cookie=a&Set-Cookie=b')
{
"code": 200,
"message": "OK",
"headers": {
"access-control-allow-credentials": "true",
"access-control-allow-origin": "*",
"content-type": "application/json",
"date": "Thu, 11 Apr 2019 19:12:55 GMT",
"server": "nginx",
"set-cookie": "b", // only one cookie
"content-length": "111",
"connection": "keep-alive"
}
}
相比之下,等效的xdmp:http-*函数行为正确:
xdmp:http-get('https://httpbin.org/response-headers?Set-Cookie=a&Set-Cookie=b')
<response xmlns="xdmp:http">
<code>200</code>
<message>OK</message>
<headers>
<access-control-allow-credentials>true</access-control-allow-credentials>
<access-control-allow-origin>*</access-control-allow-origin>
<content-type>application/json</content-type>
<date>Thu, 11 Apr 2019 19:21:40 GMT</date>
<server>nginx</server>
<set-cookie>a</set-cookie> // both cookies
<set-cookie>b</set-cookie>
<content-length>111</content-length>
<connection>keep-alive</connection>
</headers>
</response>