Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
belltown
Level 7

ifHttpAgent.GetCookies() returns bad cookies

I've noticed that ifHttpAgent.GetCookies() does not parse cookies correctly from the http header. (Tested using fw 5.5b410).

Here's code to reproduce the problem:


sub main ()
port = CreateObject ("roMessagePort")
ut = CreateObject ("roUrlTransfer")
ut.SetPort (port)
ut.SetCertificatesFile ("common:/certs/ca-bundle.crt")
ut.InitClientCertificates ()
ut.EnableCookies ()
ut.SetUrl ("https://accounts.google.com/ServiceLogin")
if ut.AsyncGetToString ()
while true
msg = Wait (0, port)
if type (msg) = "roUrlEvent"
if msg.GetInt () = 1
status = msg.GetResponseCode ()
print "Status: "; status; ". FailureReason: "; msg.GetFailureReason ()
responseHeaderList = msg.GetResponseHeadersArray ()
print "------Response Headers------"
for each responseHeader in responseHeaderList
for each item in responseHeader
print item; ": "; responseHeader [item]
end for
end for
cookieList = ut.GetCookies ("", "/")
print "------Cookies------"
for each cookie in cookieList
print cookie
end for
endif
exit while
endif
end while
endif
end sub


And here's the output:


------ Running ------
Status: 200. FailureReason: OK
------Response Headers------
Alternate-Protocol: 443:quic
Cache-control: no-cache, no-store
Content-Type: text/html; charset=UTF-8
Date: Sun, 24 Aug 2014 00:52:05 GMT
Expires: Mon, 01-Jan-1990 00:00:00 GMT
Pragma: no-cache
Server: GSE
Set-Cookie: GAPS=1:FdELrUtrjmtG3u18KBWlGwhJn3oPpA:1H3Bc1g1JlWbbcqs;Path=/;Expires=Tue, 23-Aug-2016 00:52:05 GMT;Secure;HttpOnly;Priority=HIGH
Set-Cookie: GALX=wJb5Xzs7808;Path=/;Secure
Strict-Transport-Security: max-age=10893354; includeSubDomains
Transfer-Encoding: chunked
X-Auto-Login: realm=com.google&args=continue%3Dhttps%253A%252F%252Faccounts.google.com%252FManageAccount
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
------Cookies------
Value: wJb5Xzs7808
Version: 0
Name: GALX
Path: /
Domain: accounts.google.com

Value: HIGH
Version: 0
Name: HttpOnly;Priority
Path: /
Domain: accounts.google.com

Value: 1:FdELrUtrjmtG3u18KBWlGwhJn3oPpA:1H3Bc1g1JlWbbcqs
Version: 0
Name: GAPS
Path: /
Domain: accounts.google.com
Expires: <Component: roDateTime>


It seems that if a cookie has attributes beyond just name, value, Path, Expires, and Secure, then the remaining attributes (up to the next "=" character) are taken to be the name of another cookie, and the characters after the "=" taken to be its value. So GetCookies() returns some items in its array that do not correspond to actual cookies.

Is this a bug or am I doing something wrong here?
https://github.com/belltown/
0 Kudos