Skip to content

Commit

Permalink
Merge pull request #7706 from ashcoding/TIMOB-20229
Browse files Browse the repository at this point in the history
[TIMOB-20229] Android: WebView and Cookie fix
  • Loading branch information
hieupham007 committed Feb 26, 2016
2 parents 8940402 + 9b0ec64 commit 230c9fe
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -473,31 +473,31 @@ public void removeAllHTTPCookies()
public void addSystemCookie(CookieProxy cookieURLConnectionProxy)
{
HttpCookie cookie = cookieURLConnectionProxy.getHTTPCookie();
String cookieString = cookie.getName() + "=" + cookie.getValue();
String cookieString = cookie.getName() + "=" + cookie.getValue() + ";";
String domain = cookie.getDomain();
if (domain == null) {
Log.w(TAG, "Unable to add system cookie. Need to provide domain.");
return;
}
cookieString += "; domain=" + domain;
//cookieString += " Domain=" + domain + ";";

String path = cookie.getPath();
//Date expiryDate = cookie.getExpiryDate();
boolean secure = cookie.getSecure();
boolean httponly = TiConvert.toBoolean(cookieURLConnectionProxy.getProperty(TiC.PROPERTY_HTTP_ONLY), false);
if (path != null) {
cookieString += "; path=" + path;
cookieString += " Path=" + path + ";";
}
/*
if (expiryDate != null) {
cookieString += "; expires=" + CookieProxy.systemExpiryDateFormatter.format(expiryDate);
}
*/
if (secure) {
cookieString += "; secure";
cookieString += " Secure;";
}
if (httponly) {
cookieString += " httponly";
cookieString += " Httponly";
}
CookieSyncManager.createInstance(TiApplication.getInstance().getRootOrCurrentActivity());
CookieManager cookieManager = CookieManager.getInstance();
Expand Down
1 change: 1 addition & 0 deletions ti_mocha_tests/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require('./ti.ui.slider.test');
require('./ti.utils.test');
require('./ti.analytics.test');
require('./ti.ui.textfield.test');
require('./ti.network.cookie.test');
require('./ti.ui.window.test');
require('./ti.ui.attributedString.test');
require('./ti.calendar.test');
Expand Down
27 changes: 27 additions & 0 deletions ti_mocha_tests/ti.network.cookie.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

/*
* Appcelerator Titanium Mobile
* Copyright (c) 2011-2015 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
var should = require('./should');

describe("Titanium.Network.Cookie", function () {
it("cookie", function (finish) {
var url = 'http://www.appcelerator.com/';
var d = new Date();
d.setTime(d.getTime() + (2 * 24 * 60 * 60 * 1000));
var cookie = Ti.Network.createCookie({
name : 'helloWorld',
domain : url,
value : "testCookie",
expiryDate : d,
});
should(cookie.name).eql('helloWorld');
should(cookie.getName()).eql('helloWorld');
should(cookie.url).eql(url);
should(cookie.getUrl()).eql(url);
finish();
});
});

0 comments on commit 230c9fe

Please sign in to comment.