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.

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.

“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 :slightly_smiling_face:

@belltown

Works perfectly, thank you so much for the help! And correct, you do not need the last line of your snippet.