philotas
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2016
03:32 AM
Escape (UrlEncode) within render thread without using roUrlTransfer?
I need to use the Escape function of roUrlTransfer to create a working URL.
However since the Escape function is tied to roUrlTransfer I cannot create an object on the SG render thread.
And it is overkill to have to create a roUrlTransfer anyways .. especially in another thread just to manipulate a string.
So how can I use the Escape function? Shouldn't that function be a global function instead of belonging to ifUrlTransfer?
However since the Escape function is tied to roUrlTransfer I cannot create an object on the SG render thread.
And it is overkill to have to create a roUrlTransfer anyways .. especially in another thread just to manipulate a string.
So how can I use the Escape function? Shouldn't that function be a global function instead of belonging to ifUrlTransfer?
9 REPLIES 9
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2016
11:12 AM
Re: Escape (UrlEncode) within render thread without using roUrlTransfer?
Hahaha, that's a good one!
You can't - sorry.
As an excercise of ridiculousness, maybe create a persistent "UrlEncoder" Task thread, with "input" and "output" field, then put observer on the output and shove the URL in the input, wait for a call back... that'd be a good Karnapidasana
You can't - sorry.
As an excercise of ridiculousness, maybe create a persistent "UrlEncoder" Task thread, with "input" and "output" field, then put observer on the output and shove the URL in the input, wait for a call back... that'd be a good Karnapidasana


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2016
12:22 PM
Re: Escape (UrlEncode) within render thread without using roUrlTransfer?
"philotas" wrote:
I need to use the Escape function of roUrlTransfer to create a working URL.
However since the Escape function is tied to roUrlTransfer I cannot create an object on the SG render thread.
And it is overkill to have to create a roUrlTransfer anyways .. especially in another thread just to manipulate a string.
So how can I use the Escape function? Shouldn't that function be a global function instead of belonging to ifUrlTransfer?
Thanks for raising the issue. I've filed a feature request for this.
philotas
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2016
02:44 AM
Re: Escape (UrlEncode) within render thread without using roUrlTransfer?
"EnTerr" wrote:
Hahaha, that's a good one!
You can't - sorry.
As an excercise of ridiculousness, maybe create a persistent "UrlEncoder" Task thread, with "input" and "output" field, then put observer on the output and shove the URL in the input, wait for a call back... that'd be a good Karnapidasana
haha, good one too! Sometimes feeling the same!
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2016
01:32 PM
Re: Escape (UrlEncode) within render thread without using roUrlTransfer?
"philotas" wrote:
haha, good one too! Sometimes feeling the same!
Sadly, i could not come with a short and elegant workaround - or i would have suggested it. The fact that the (un)usually resourceful RokuKC and theEndless didn't either, also speaks.
You could write your own function that goes over the string character by character - and %-escape the ones that are not "unreserved". A roRegEx might come handy to check against, something like "[\w\d\-_.~]". And not to forget UTF8-escaping the ones with ASC() > 255 ... so nevermind, probably better to do roByteArray.FromAsciiString() and then toHexString() everything and insert % before every two chars... a rather bad way.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2016
10:39 PM
Re: Escape (UrlEncode) within render thread without using roUrlTransfer?
Here, i whipped a band-aid:
function url_encode(s):
unreserved = createObject("roRegex", "[\w\d\-_.]", "")
ba = createObject("roByteArray")
res = ""
for each ch in s.split(""):
if unreserved.isMatch(ch):
res += ch
else:
ba.fromAsciiString(ch): hex = ba.toHexString()
for i = 1 to len(hex) step 2: res += "%" + mid(hex,i,2): next
end if
next
return res
end function

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2016
11:03 PM
Re: Escape (UrlEncode) within render thread without using roUrlTransfer?
I'm curious about the use-case. What is the situation in which you need to URL encode a value in a separate thread from the actual web request?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016
11:43 AM
Re: Escape (UrlEncode) within render thread without using roUrlTransfer?
"TheEndless" wrote:
I'm curious about the use-case. What is the situation in which you need to URL encode a value in a separate thread from the actual web request?
Umm... i can easily see the need if using one of the media playback noids - "Audio" and "Video" (AKA the Roku bread and butter 8-) )?
Say the media server for whatever reasons (security, analytics, accounting) requires you to pass it some varying magic either as a query or a cookie.or a header - and needing that url-encoded. Such needs will incur in the render thread, would it not?
philotas
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016
01:26 PM
Re: Escape (UrlEncode) within render thread without using roUrlTransfer?
"TheEndless" wrote:
I'm curious about the use-case. What is the situation in which you need to URL encode a value in a separate thread from the actual web request?
I load data from a server in order to show images and text in a long row list.
Until the server is updated to deliver working URLs I need to construct the URL for the Poster component in the sg thread.
I could probably do the when loading the data, but then most of theses genereted URLs might never be used so it is not a good idea to prepare them "just in case".
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2016
05:04 PM
Re: Escape (UrlEncode) within render thread without using roUrlTransfer?
Note for posterity: in 7.5, the issue has been resolved by adding new string methods: EncodeUriComponent(), DecodeUriComponent() and a couple more.