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.
We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.
Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality.
In the meantime, for additional assistance, visit our Support Site.
Thanks for your patience — we’re excited to share what’s next!