[TIMOB-13885] iOS: I can't send more than one cookie
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Reopened |
Resolution | Unresolved |
Affected Version/s | Release 3.1.0, Release 3.2.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | parity |
Reporter | Matej |
Assignee | Unknown |
Created | 2013-05-13T12:07:20.000+0000 |
Updated | 2018-02-28T20:03:59.000+0000 |
Description
*Problem*
Unfortunately with an iOS I can't use/send more than one cookie. With Android it is working without any problems.
*Test case*
var win = Titanium.UI.createWindow();
var xhr = Ti.Network.createHTTPClient();
xhr.open("GET", "http://www.some.where");
xhr.setRequestHeader("Cookie", "cookieName=value; nextCookieName=nextValue;");
xhr.send();
win.open();
*Log*
[ERROR] invalid arguments for setting cookie. value should be in the format 'name=value'. in -[TiNetworkHTTPClientProxy setRequestHeader:] (TiNetworkHTTPClientProxy.m:465) [WARN] Exception in event callback. { line = xxx; message = "invalid arguments for setting cookie. value should be in the format 'name=value'. in -[TiNetworkHTTPClientProxy setRequestHeader:] (TiNetworkHTTPClientProxy.m:465)"; sourceId = 366760928; sourceURL = "file://localhost/Users/xxx/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/1EC7C0B6-34E5-4D96-9D79-0685610566E7/xxx.app/xxx.js"; }
*Workarounds*
http://developer.appcelerator.com/question/120728/set-cookies-using-setrequestheader--crashed-
if (Titanium.Platform.name == 'iPhone OS')
{
xhr.setRequestHeader("Cookie", "cookie1=value1");
xhr.setRequestHeader("Cookie", "cookie2=value2");
}
else
{
var cookieString = "cookie1=value1; cookie2=value2;";
xhr.setRequestHeader('Cookie', cookieString);
}
have you referenced this Q&A? http://developer.appcelerator.com/question/120728/set-cookies-using-setrequestheader--crashed-
Yes, I know that I can solve that problem like this... But firstly: If I have too many cookie there's too many work with this. On Android is it working without any problems. I would be very happy if it worked also with iOS. I think that much better is fix this main bug in the Ti than fix it somewhere in the normal application every time. Problem is that this is not only one bug in the Ti/My app. There are too many bugs and my source code than looks absolutely terrible (Everywhere some fix). Also I have to make too much changes between iOS/Android because... Simply awfully. Thank you for understanding ;)
Absolutely understood. I just wanted to have a workaround at your disposal until this can be properly escalated to the platform team. It seems to be quite clearly a parity issue, that as you state, developers should not need to account for and should be fixed in Titanium.
So I'm guessing that the following
returns multiple variables like
Is that right? It would be useful to have a complete simple test case that I can drop into an app.js, run and reproduce the error. With that I can escalate it to engineering. Thanks.
Yes, you are right. Here is little sample:
Tested and confirmed on iOS 6 simulator with Ti SDK 3.1 GA and 3.2 CI.
Just ran into this. If cookie values have to be set separately for some reason on iOS, the Titanium code should definitely handle this. Users apps shouldn't hard crash for attempting to set a completely valid and normal "Cookie" header value.
Any idea when this issue will be addressed?