none
MXLHTTP 302 status RRS feed

  • Question

  • I am using Microsoft.XMLHTTP to make a request and the response to this request invloves a redirect, is there anyway to capture the header information on the original response before it's redirected?

     I can see the first response's header information using fiddler which comes back with status of 302(redirection) but using the XMLHTTP I only see the header information for final response which is the result of a redirection.

    oHttp = new ActiveXObject("Microsoft.XMLHTTP");

    .... ....

    oHttp.onreadystatuschange = handleResponse;

    function handleResponse(){

    if (o.status == 302){

    alert('');

    }

    }

    but this creates an error , from documentation it sounds like this condition oHttp.readystate == 4 needs to be met before I can access the oHttp.status but at that point oHttp.status is 200 which means the redirection has already taken place.

    Thanks,

    Friday, May 5, 2006 10:14 PM

Answers

  • Let me cite Stephen Sulzer's answer from an old thread, it relates to XMLHTTP as well:

    //ServerXMLHTTP does not have an option to intercept a 301/302/303/307 redirect response. If you need to capture the redirect response, you will need to use the WinHttpRequest object instead. WinHttpRequest is the component that ServerXMLHTTP uses to send an HTTP request. WinHttpRequest has an option to disable automatic redirect following, and it implements an interface similar to ServerXMLHTTP, so switching your code is easy. WinHttpRequest will already be available on your system if you have MSXML 4.0 and/or are running on Windows 2000 SP3/SP4, Windows XP SP1/SP2 or Windows Server 2003.//

    WinHttpRequest documentation:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winhttp/http/winhttprequest.asp

    To control redirects, set WinHttpRequestOption_EnableRedirects option:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winhttp/http/winhttprequestoption.asp

    Sets or retrieves a VARIANT that indicates whether requests are automatically redirected when the server specifies a new location for the resource.  The default value of this option is VARIANT_TRUE to indicate that requests are automatically redirected.

    Saturday, May 6, 2006 12:39 AM