标题没有设置为javascript

时间:2014-05-09 17:38:43

标签: javascript http-headers

当我发送带有自定义标头和GET方法的XHR时,我遇到了问题:

  1. 方法更改为OPTION
  2. 标头未设置
  3. 我的要求:

    var xhr = new XMLHttpRequest()
        xhr.open("GET", "http://api.pms.dev/v1/users", true);
        xhr.setRequestHeader('Authorization', "Basic " + 'dsfsdfsdfsdfdsf');
    
        xhr.send();
    

    回复机构:

    Remote Address:192.168.56.121:80
    Request URL:http://api.pms.dev/v1/users
    Request Method:OPTIONS
    Status Code:401 Unauthorized
    
    Accept:*/*
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,de;q=0.2,it;q=0.2,uk;q=0.2,es;q=0.2
    Access-Control-Request-Headers:authorization
    Access-Control-Request-Method:GET
    Cache-Control:max-age=0
    Connection:keep-alive
    Host:api.pms.dev
    Origin:null
    User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/34.0.1847.116 Chrome/34.0.1847.116 Safari/537.36
    

0 个答案:

没有答案