According to the manual the correct syntax for getResponseHeadersArray is to have a string in the ().
Object GetResponseHeadersArray(String feature)
• Returns an roArray of roAssociativeArrays. Each associative array contains a single
header name/value pair.
However any string I put in there gives me:
Member function not found in BrightScript Component or interface.
I was hoping I could get just one set of response headers, Set-Cookie (of which there are quite a few) instead of 58 headers which I will need to iterate through looking for that one Set-Cookie that contains the string I’m looking for. If it did work properly, I would still have to do some iteration, just not as much.
Seems that it only works with () instead of (“Set-Cookie”) or any other text.
Documentation is on page 97 of the 2.7 SDK Component reference.
If it helps, here’s a function I wrote for one of my channels…
Function GetCookieValueFromHeaders( cookieName As String, headersArray As Object ) As String
cookieValue = ""
For Each header in headersArray
If header[ "Set-Cookie" ] <> invalid And header[ "Set-Cookie" ].InStr( cookieName + "=" ) = 0 Then
cookieValue = header[ "Set-Cookie" ].Mid( cookieName.Len() + 1 )
cookieValue = cookieValue.Mid( 0, cookieValue.InStr( ";" ) )
Exit For
End If
Next
Return cookieValue
End Function
instr is zero-based in first context, one based in the second context!
cookieValue = header[ “Set-Cookie” ].Mid( cookieName.Len() + 1 )
snip off the cookee name
cookieValue = cookieValue.Mid( 0, cookieValue.InStr( “;” ) )
snip off the string after the end of the cookie value and it’s good to go!
I just came across this section of the Roku component reference earlier today (page 15/16 in 2.7), had never tried to use these functions in that way before today, synchronicity!
Funny… When I posted it, I said to myself, “I should probably put comments in here”, but I’m far too lazy for that…
There was a thread awhile back about the differences between the standalone versions of InStr and the instance versions (I think it’s the same for Mid as well). If I had to guess, I’d say Roku went that route for familiarity for developers. For example, in VBScript InStr() is 1 based, whereas in VB.Net the .InStr() method is 0 based, so, if you’re used to using VBScript, a 0 based InStr standalone function might confuse you, and vice versa if you used to using .Net. Total speculation, but it seems like a reasonable explanation to me…