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: 

Specifying headers for a Poster url

Hi,

I have an issue where I need to grab images from a service that requires unique headers in order to gain access (server denies access unless header is present). Is there a way to specify headers that can be used by the Poster class when fetching the image from the url? Or is this type of functionality not possible?

Thanks.
0 Kudos
3 REPLIES 3
belltown
Roku Guru

Re: Specifying headers for a Poster url

A Poster is an roSGNode which implements the ifSGNodeHttpAgentAccess interface, which provides access to a node's roHttpAgent object, which implements the ifHttpAgent interface.

Therefore, you should be able to do something like:

posterHttpAgent = posterNode.getHttpAgent()
posterHttpAgent.AddHeader("HeaderName", "HeaderValue")
'posterNode.setHttpAgent(posterHttpAgent)  <== This line is not needed!

(not sure if you need that last line of code or not)

A node inherits its parent's roHttpAgent object, so you should be able to set the headers on a Poster ancestor, rather than setting it for each individual Poster.

Note, I haven't tried this yet, so no guarantee if this will work or not. Try it and report back if you have problems.
0 Kudos
EnTerr
Roku Guru

Re: Specifying headers for a Poster url

"belltown" wrote:
(not sure if you need that last line of code or not)

A node inherits its parent's roHttpAgent object, so you should be able to set the headers on a Poster ancestor, rather than setting it for each individual Poster.

If my understanding of this is correct - you'll have to do this only once per program run (Scene, in fairness) - since everything hanging in the tree has been inheriting the roHttpAgent - back to the very Top. Baring Audio and Video nodes, which take exception.

To that, doing .setHttpAgent() is unnecessary. That's me speaking from my doco-reading armchair 🙂
0 Kudos

Re: Specifying headers for a Poster url

@belltown

Works perfectly, thank you so much for the help! And correct, you do not need the last line of your snippet.
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.