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: 

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 4
RokuMarkn
Visitor

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
Roku Guru

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.
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
Roku Guru

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
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.