2014-11-30 3 views
4

나는 성공적 그러나xml.HTTP.Request에 대한 referer 설정?

var createCORSRequest = function(method, url) { 
    var xhr = new XMLHttpRequest(); 
    if ("withCredentials" in xhr) { 
    // Most browsers. 
    xhr.open(method, url, true); 
    } else if (typeof XDomainRequest != "undefined") { 
    // IE8 & IE9 
    xhr = new XDomainRequest(); 
    xhr.open(method, url); 
    } else { 
    // CORS not supported. 
    xhr = null; 
    } 
    return xhr; 
}; 

var url = 'http://www.whatismyip.com'; 
var method = 'GET'; 
var xhr = createCORSRequest(method, url); 

xhr.onload = function() { 
    // Success code goes here. 
}; 

xhr.onerror = function() { 
    // Error code goes here. 
}; 


xhr.setRequestHeader('referer', 'http://www.google.com'); 
xhr.send(); 

를 사용하여 xml.http.request 보내고, 내 리퍼러를 정의 할 수 couldnt한다. 맞춤 리퍼러를 추가하는 올바른 방법은 무엇입니까?

답변

11

수 없습니다. XMLHttpRequest specification forbidsreferer 헤더를 변경합니다 (일부 사이트에서 리퍼러를 사용하는 보안 검사를 우회하기 위해 사이트를 중지 시킴). 헤더는 다음 헤더 중 하나에 대한 대소 문자를 구분하지 일치하는 경우

다음 단계를 종료 :

  • 이 ... ...
  • 리퍼러