AJAX 요청에 대한 디버그 도구를 구축 중이며 요청/응답 헤더를 표시하고 싶습니다 (Firebug가하는 것처럼). jqXHR.getAllResponseHeaders을 사용하여 응답 헤더를 얻을 수 있지만 요청 헤더 에 해당하는 값이 있습니까?
하지 않으면, 내가 어느 정도 그것을 자신을 재구성 할 수 알고 :
GET /blah // this part is easy
Host: servername.com // pretty easy
Accept: ???
Referer: ??? // just use current page url?
User-Agent: // easy from navigator.userAgent
X-Requested-With: XMLHttpRequest // hardcoded, $.ajax always does this?
Accept-Charset: ???
Accept-Encoding: ???
Accept-Language: ???
Connection: ???
나는 대부분에 대해 Accept
관심. 브라우저 또는 뭔가가 바뀌고있는 것 같습니다. 왜냐하면 나는 $.ajax({dataType:'json'})
을 설정하고 있기 때문에 방화범이 끌리는 사람은 Accept application/json, text/javascript, */*; q=0.01
입니다. 전송되는 실제 헤더를 캡처 할 수 있기를 바랍니다.
Referer
의 경우 window.url을 사용하는 것이 안전할까요?
Accept-*
또는 Connection
값을 얻는 방법을 모르겠습니다.
가능한 중복 [XMLHttpRequest에서 보낸 Sent 헤더] (http://stackoverflow.com/questions/7564007/get-sent-headers-in-an-xmlhttprequest) –