Function http_get_to_string_with_retry() as String
timeout% = 1500
num_retries% = 5
str = ""
while num_retries% > 0
' print "httpget try " + itostr(num_retries%)
if (m.Http.AsyncGetToString())
event = wait(timeout%, m.Http.GetPort())
if type(event) = "roUrlEvent"
print event.GetResponseCode(); " ";
print event.GetFailureReason()
headers = event.GetResponseHeaders()
printAA( headers )
str = event.GetString()
exit while
elseif event = invalid
print "Invalid Event ";
m.Http.AsyncCancel()
REM reset the connection on timeouts
m.Http = CreateURLTransferObject(m.Http.GetUrl())
timeout% = 2 * timeout%
else
print "roUrlTransfer::AsyncGetToString(): unknown event"
endif
endif
num_retries% = num_retries% - 1
print "HTTP RETRY: " + itostr( num_retries% )
end while
return str
End Function
Function ResolveRedirect(str As String) As String
http = CreateObject("roUrlTransfer")
http.SetUrl( str )
event = http.Head()
headers = event.GetResponseHeaders()
redirect = headers.location
if ( redirect <> invalid AND redirect <> str )
print "Old url: " str
print "Redirect url: " redirect
str = redirect
endif
return str
End Function
"migmigmig" wrote:
One thing I noticed was that I couldn't do the redirect "late" -- if I tried to resolve the redirect in the error handler, I couldn't prevent the box from closing the screen. It seems like the video screen visibly closes before you actually get the error, so all you can do is reopen the video window, which causes a visible glitch as it momentarily goes back to the details screen.