Add header to http request
<p>My first post here. 
I'm using droidscript and I have to include an header that contains a specific user and a password in order to retrieve a token. I'm having trouble because I don't know where to include those headers.</p>

<p>That's the code I'm using:</p>

<pre><code>function btn_OnTouch(){

    var url = "myurl";
    SendRequest(url);

}

//Send an http get request.

function SendRequest(url){

    var httpRequest = new XMLHttpRequest();

    httpRequest.onreadystatechange = function() {
        HandleReply(httpRequest);
    };

    httpRequest.open("GET", url, true);

    httpRequest.send(null);

    app.ShowProgress("Loading...");

}

//Handle the servers reply (a json object).

function HandleReply(httpRequest){

    if (httpRequest.readyState == 4){

        //If we got a valid response.

        if (httpRequest.status == 200){
            txt.SetText("Response: " + httpRequest.status + httpRequest.responseText);
        }

        //An error occurred
        else
            txt.SetText("Error: " + httpRequest.status + httpRequest.responseText);

    }

    app.HideProgress();

}
</code></pre>

<p>The told me I should probably include the headers like this, but I don't know where to put them in my code.</p>

<pre><code>httpRequest.setRequestHeader(“username”, “myuser”);

httpRequest.setRequestHeader(“password”, “mypass”);
</code></pre>