Can you detect 301 redirect with Microsoft.XMLHTTP object?

I am using VBScript and a Microsoft.XMLHTTP object to clear some web data. I have a list of URLs to check, but unfortunately some 301 are redirected to others in the list, so I end up with redundant data.

Is it possible for an XMLHTTP object to fail with a 301 redirect? Or at least cache the original response header? Or else just let me know what happened?

(notes: I have no control over the server from which I request data, when I receive new data, I could check if it is redundant, but I would like to avoid this if possible).

We will be very grateful for any ideas.

+3
source share
1 answer

Firstly, the ProgId you should use is MSXML2.XMLHTTP.

Answer: No . MSXML2.XMLHTTP automatically follows redirects.

If you need to track and possibly not follow redirects, you can use the WinHttp.WinHttpRequest object , which, like MSXML2.XMLHTTP, is available for the script. This is actually an object that MSXML2.XMLHTTP delegates to download HTTP.

You need to set WinHttpRequestOptions to EnableRedirects.

See this Q&A at social.msdn.microsoft.com for more information .

+2

Source: https://habr.com/ru/post/1740194/


All Articles