我正在尝试使用 anyorigin.com 服务将自定义标头发送到远程网站,但由于某种原因,用户代理标头未传递到远程站点!
证明标头未发送来自我从 www.whatsmyuseragent.com 返回的响应,该响应显示了与我发送的用户代理不同的用户代理!
谁能告诉我为什么用户代理标头没有传递到远程网站?
<html>
<head>
<script src="http://anyorigin.com/jquery-1.4.2.min.js"></script>
<script>
$.ajax({
url: 'http://anyorigin.com/get?url=http://www.whatsmyuseragent.com/&callback=?',
xhr: {
withCredentials: true
},
type: 'GET',
dataType: "json",
success: displayAll,
beforeSend: setHeader
});
function displayAll(data){
// alert(data.contents);
document.myform2.outputtext2.value = data.contents ;
}
function setHeader(xhr){
xhr.setRequestHeader("User-Agent","Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3");
}
</script>
</head>
<body>
<br>
<form id="myform2" name="myform2" action="./5.php?Id=&title=" method="post">
<td><textarea rows="14" cols="15" name="outputtext2" style="width: 99%;"></textarea> </td>
</form>
</html>