由于测试的时候需要模拟Head请求,先访问要请求的站点,然后在浏览器的控制台下执行如下代码即可。
var xmlHttp;
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
xmlHttp.open("Head","http://localhost:8080/test",true);
xmlHttp.send();