4 Replies Latest reply on Jan 20, 2010 7:07 AM by Dragos GEORGITA

    setRequestHeader not working in air app?

    mauri824

      Most of this is sample code. What I'm doing here is trying to pass the user agent http header but it is not doing the trick

      I was trying this in a larger project but created a small project to test this

       

      What are the limitations of this function?

       

      I also tried setting cookie headers

       

      req.setRequestHeader('Cookie', 'test=test');

       

      but didnt have any luck

       

      function doRequest(url) {

                     var req = new XMLHttpRequest();

        

                     req.onreadystatechange = function() {

                          if (req.readyState == 4) {

                              var str = req.responseText;

                              if (str.length > 800) {

                                  str = str.substring(0, 799);

                                  str += "..";

                              }

                              alert('readystate: ' + req.readyState + '\n' +

                                  'status/statusText: ' + req.status + '/' +

                                   req.statusText + '\n' +

                                  'responseText (400 chars): '  + "\n\n" + str);

                          }

                      };

                      req.open('GET', url, true);

          var agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008100922 Ubuntu/8.04 (hardy) Firefox/3.0.3";

              req.setRequestHeader('User-Agent', agent);

              req.send(null);           

                  }

       

                         }