아래를 html로 저장하여 메소드 테스트 및 응답 헤더를 확인 가능하다.
<div id="optdiv">응답에 Allow 헤더가 있으면 출력됨</div>
<script>
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
document.getElementById("optdiv").innerHTML=this.getResponseHeader("Allow");
console.log(this.responseText);
}
});
xhr.open("OPTIONS", "https://www.xxx.co.kr/");
xhr.setRequestHeader("save-data", "on");
xhr.setRequestHeader("upgrade-insecure-requests", "1");
xhr.setRequestHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
xhr.setRequestHeader("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
xhr.setRequestHeader("accept-encoding", "gzip, deflate, br");
xhr.setRequestHeader("accept-language", "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("postman-token", "e90f3904-3224-dfbd-58b1-a97db2e18254");
xhr.send(data);
</script>
댓글 달기