在MarkLogic Servie端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>
答案 0 :(得分:1)
JSON每个名称只能代表一个字段。 解析器显然正在工作。 似乎缺少对Json中多值http标头的支持。 可以采用许多方法来完成,但是全部都是内部修复。 您可以尝试调用xdmp.eval并将xquery版本与xml结果一起使用,然后读取xml或以更合适的格式转换为json。