Issue Description:
There is a issue with “getCookies” API in “roURLTransfer”. This API is not returning back proper cookie object if the set-cookie header contains Max-Age parameter. The Max-Age parameter is very common in use in the recent past. So when server response header has cookies with Max-Age the cookie object returned in getCookies API is something as given below:
Cookie return object print:
<Component: roArray> =
<Component: roAssociativeArray> =
{
* Domain: “devunne.com”*
* Name: “testcookie2”*
* Path: “/”*
* Value: “testing2”*
* Version: 0*
}
<Component: roAssociativeArray> =
{
* Domain: “devunne.com”*
* Expires: <Component: roDateTime>*
* Name: “Max-Age”*
* Path: “/”*
* Value: “36000000”*
* Version: 0*
}
<Component: roAssociativeArray> =
{
* Domain: “devunne.com”*
* Name: “testcookie1”*
* Path: “/”*
* Value: “testing1”*
* Version: 0*
}
Test URL which returns cookies with Max-Age:
http://devunne.com/development/cookietest.php
In the above case you can see that the Max-Age is returned as another cookie object, and the actual cookies are not having any Expire time.
Code Snippet:
function AsyncRequest()
* url = “http://devunne.com/development/cookietest.php”*
* xfer = CreateObject(“roURLTransfer”)*
* port = CreateObject(“roMessagePort”)*
* xfer.SetMessagePort(port)*
* url = encodeUrlParams(url)*
* xfer.EnableCookies()*
* xfer.SetUrl(url)*
* respData = invalid*
* raw = invalid*
* stat = xfer.AsyncGetToString() *
* print url*
* if stat = true*
* while (true)*
* msg = wait(0, port)*
* if (type(msg) = “roUrlEvent”)*
* code = msg.GetResponseCode()*
* respData = invalid*
* print “Response Code: “*
* print code*
* if (code = 200)*
* cookies = xfer.getCookies(””, “/”) *
* raw = msg.GetString()*
* print cookies*
* *
* *
* *
* else if (code < 0 )*
* xfer.AsyncCancel() *
* endif*
* else if (event = invalid)*
* xfer.AsyncCancel()*
* endif *
* end while*
* endif *
end function
Understanding:
Its clearly issue with the API when there is Max-Age parameter added we have done extensive check regarding the issue. The problem does not occur if there is no Max-Age parameter in cookie. Below is the screenshot of the cookie from the browser.
[upload|Us57x3RiWlRZje7SAV1f+w==]
