Finally, the long-awaited download function was added to filetransfer
recently on github.
But when check android code, i cannot find any cookie related
code.Does it handle cookies?In widespread situations we need some
session cookie to authenticate before downloading.
For now i can add few lines myself to add cookie handler in my android
re-building,but i know nothing about ios native code.
Can anyone here give me some hints?
Thx~
// Set the cookies on the response
String cookie = CookieManager.getInstance().getCookie(source);
if (cookie != null) {
connection.setRequestProperty("Cookie", cookie);
}
It is similar to the upload function.
On iOS you could try to allow all cookies:
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage
sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
//NSArray* cookies = [cookieStorage cookiesForURL:[NSURL
URLWithString:sourceUrl]];
At the moment I don't have a test case for this.
On andriod, your provided codes work very well;
On iOS, it seems no need to use "setCookieAcceptPolicy", because in
source file PhoneGapDelegate.m, sharedHTTPCookieStorage already set to
"NSHTTPCookieAcceptPolicyAlways".Change nothing and work fine.