Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 

Get, read user-agent in brightscript

Hi,

Is there a way to get the user-agent in brightscript?
I know you can set it, but didn't find a way to read.
I've been reading through the forum and found already a few threads asking about it...but there was never a proper answer to that.

Thank you
Simon
0 Kudos
4 Replies
RokuMarkn
Level 7

Re: Get, read user-agent in brightscript

Use one of the Async methods of roUrlTransfer and you can read the server's headers via GetResponseHeaders.

--Mark
0 Kudos
belltown
Level 7

Re: Get, read user-agent in brightscript

"RokuMarkn" wrote:
Use one of the Async methods of roUrlTransfer and you can read the server's headers via GetResponseHeaders.

--Mark

I think he was asking about the Roku's user-agent string. GetResponseHeaders() only gets headers sent back from the server, and servers don't send a User-Agent header.

The Roku's User-Agent header appears to be "Roku/DVP-x.y (zzzzzzzzzzzzz)",

Where:
x is the major version number of the firmware (no leading zeros)
y is the minor version number of the firmware (no leading zeros)
zzzzzzzzzzzzz is the 13-character string corresponding to the Roku's version number as returned by ifDeviceInfo.GetVersion()

I'm sure there's no guarantee that won't change, although if it's something you care about, you can set it yourself to whatever you want.
https://github.com/belltown/
0 Kudos

Re: Get, read user-agent in brightscript

Hi,

Yes like belltown said I'm looking for the Roku user-agent.
So there is no direct way to read that? If not I'll probably make one myself like belltown suggested.

Simon
0 Kudos
belltown
Level 7

Re: Get, read user-agent in brightscript

It's a bit over-the-top, but you could always send an async Url request from your Roku to itself and read the User-Agent response header.

To get the Url, something like this should work:


ipAddrs = CreateObject ("roDeviceInfo").GetIpAddrs ()
for each key in ipAddrs
loopbackUrl = "http://" + ipAddrs [key] + ":8060"
exit for
end for
https://github.com/belltown/
0 Kudos