sinon fakeserver 可以发送 xml 响应吗?
Can sinon fakeserver send xml response?
我想伪造一个响应在 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
]);
我想伪造一个响应在 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
]);