我想伪造其响应位于xml中的服务器。我怎样才能做到这一点?
server.respondWith(
"GET",
"testurl",
[
200,
{
"Content-Type": "application/xml",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "max-age=0, must-revalidate",
"Connection": "close"
},
<note></note>
]
);
当您使用模仿响应时respondWith
,方法的第三个参数是描述所需响应的数组。数组的第三个元素<note></note>
是响应的主体,因此您可以将XML作为字符串放置在此处。
var xml = getXmlStringSomehow();
server.respondWith(
"GET",
"testurl",
[
200,
{
"Content-Type": "application/xml",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "max-age=0, must-revalidate",
"Connection": "close"
},
xml
]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句