Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
TheEndless
Channel Surfer

Re: maximum URL length?

"jbrave" wrote:
Ok, so just to make sure I get it, what is the criteria for whether a character should be URL encoded? one website I looked at said "all non-alphanumerics", but I think I really only want the "weird" characters like spaces and brackets?

- Joel

You can just use the roURLTransfer object's Escape method, and not even worry about it. If you don't want to do it dynamically, then you can use a site like this: http://www.opinionatedgeek.com/dotnet/t ... ncode.aspx
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)
0 Kudos
renojim
Community Streaming Expert

Re: maximum URL length?

That site encodes everything, slashes and all. I know this was all very confusing to me when I was trying to put a caret in a URL. I never did solve that problem.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
TheEndless
Channel Surfer

Re: maximum URL length?

"renojim" wrote:
That site encodes everything, slashes and all. I know this was all very confusing to me when I was trying to put a caret in a URL. I never did solve that problem.

-JT

Right, you'd need to enter the individual parameters and values separately. The point was it's an easy way to encode instead of trying to figure it out manually yourself.
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)
0 Kudos
renojim
Community Streaming Expert

Re: maximum URL length?

I guess it would be nice to have one function to do everything for you. It doesn't seem like it would be too hard to do. Maybe the next time I need the functionality I'll do it. Doing one parameter at a time just seems like a pain.

-Jt
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
RokuMarkn
Visitor

Re: maximum URL length?

"renojim" wrote:
I guess it would be nice to have one function to do everything for you. It doesn't seem like it would be too hard to do. Maybe the next time I need the functionality I'll do it. Doing one parameter at a time just seems like a pain.


Hm, I'm not sure what you mean by "do everything for you", but I don't see how it would be possible to pass a URL to a function and have it automatically pick out the parameters and encode them. Suppose you were passing an arithmetic expression to a URL, like
www.calculate.com?expr=x=2+3&0xff&precision=10
How could it figure out that the first and third equals signs shouldn't be encoded, but the second one should be? And that the first ampersand should be encoded, but the second one shouldn't? If it were possible to figure this out automatically in all cases, the web site itself could do it and there would be no need to encode anything.

--Mark
0 Kudos
renojim
Community Streaming Expert

Re: maximum URL length?

Well I'm sure there will always be cases that would have to have special handling. I meant for the generic case like:
http://somehost.com/path1/path2/query.p ... &q3=param3
where the parameters don't contain ampersands or equal signs, which would probably cover the vast majority of cases.

Even in your case it should be possible to figure out where the parameters begin and end. It might not be trivial, but not impossible. Sounds like a challenge.

Of course, there's always the argument to be made that how tough is it to encode each parameter as the URL is being built, so maybe I'm just being lazy. It just seems to be a misnomer to have a function called UrlEncode that doesn't actually encode a full URL.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
TheEndless
Channel Surfer

Re: maximum URL length?

URLEncode means "encode this string for use in a url", not "encode this url"...
Another thing to consider with a function that does it for you is that you could end up encoding multiple times if you're not careful. All that said, though, if you're building the URL programmatically with string concatenation anyway, why's it any more difficult to wrap the bits in a UrlEncode() call?
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)
0 Kudos
kbenson
Visitor

Re: maximum URL length?

"renojim" wrote:

Even in your case it should be possible to figure out where the parameters begin and end. It might not be trivial, but not impossible. Sounds like a challenge.


The problem is that there are cases where it absolutely isn't possible. For example, encoding a partial query string as a parameter...

To answer jbrave's earlier question about knowing what to encode, just encode every query param and value if there's any possibility you might run into a character that's illegal. In most cases you can get by without it, but if the params or values are in any way generated from user input, you'll almost definitely run into a problem at some point.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos