charliealbright
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017
01:41 PM
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.
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.
3 REPLIES 3
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017
02:05 PM
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:
(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.
Therefore, you should be able to do something like:
posterHttpAgent = posterNode.getHttpAgent()
posterHttpAgent.AddHeader("HeaderName", "HeaderValue")
'posterNode.setHttpAgent(posterHttpAgent) <== This line is not needed!
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.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017
02:38 PM
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 🙂
charliealbright
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017
02:42 PM
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.
Works perfectly, thank you so much for the help! And correct, you do not need the last line of your snippet.