04-04-2015, 06:05 AM
There are many ways of URL redirection. IntGetFile redirects only when used HTTP error 301 with "Location" header. Then it is possible to get the "Location" header. Example:
Macro Macro2538
If used other ways, IntGetFile does not redirect. But then in most cases you can extract the new location from the downloaded page HTML or headers. Then call IntGetFile again with the new location.
Macro Macro2538
out
str url="http://www.quickmacros.com/test/test.php"
str html headers
IntGetFile url html 0 INTERNET_FLAG_NO_AUTO_REDIRECT 0 0 0 headers
;out html
out headers
str location
if findrx(headers "^HTTP/\S+ 301\b(?sm).+^Location: *([^\r\n]+)" 0 1 location 1)>=0
,out F"Redirected to {location}[][]"
,
,IntGetFile url html
,out html
If used other ways, IntGetFile does not redirect. But then in most cases you can extract the new location from the downloaded page HTML or headers. Then call IntGetFile again with the new location.