From callback-dev-return-9884-apmail-incubator-callback-dev-archive=incubator.apache.org@incubator.apache.org Thu Jul 12 15:28:35 2012 Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4BA78D6D5 for ; Thu, 12 Jul 2012 15:28:35 +0000 (UTC) Received: (qmail 12600 invoked by uid 500); 12 Jul 2012 15:28:35 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 12568 invoked by uid 500); 12 Jul 2012 15:28:35 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 12548 invoked by uid 99); 12 Jul 2012 15:28:34 -0000 Received: from issues-vm.apache.org (HELO issues-vm) (140.211.11.160) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jul 2012 15:28:34 +0000 Received: from isssues-vm.apache.org (localhost [127.0.0.1]) by issues-vm (Postfix) with ESMTP id 9EDED1404B1 for ; Thu, 12 Jul 2012 15:28:34 +0000 (UTC) Date: Thu, 12 Jul 2012 15:28:33 +0000 (UTC) From: "Andrew Grieve (JIRA)" To: callback-dev@incubator.apache.org Message-ID: <1887209130.42197.1342106914652.JavaMail.jiratomcat@issues-vm> In-Reply-To: <1568281131.78.1337032592287.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (CB-765) Header support for PhoneGap's FileTransfer (Upload) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13412877#comment-13412877 ] Andrew Grieve commented on CB-765: ---------------------------------- Yeah, I think Ionut has a point. It would make a lot more sense to have the headers be attached to the options object instead of a magic key of params. The point about allowing multiple headers with the same name is valid as well, but maybe low enough priority that it can wait for XHR2? I can take on adding the headers to FileUploadOptions and the relevant changes to iOS & Android. What do you think about removing the existing support for having headers on the params object though? My vote would be to remove support for this on iOS, but leave it in on Android since it's new on iOS but has existed for a little while on Android. > Header support for PhoneGap's FileTransfer (Upload) > --------------------------------------------------- > > Key: CB-765 > URL: https://issues.apache.org/jira/browse/CB-765 > Project: Apache Cordova > Issue Type: Improvement > Components: iOS > Affects Versions: 1.7.0 > Reporter: Aurelien MERCIER > Assignee: Herm Wong > Fix For: 1.9.0 > > Original Estimate: 1h > Remaining Estimate: 1h > > It would be great to support headers for FileTransfer's iOS version (as done in Android: CB-78). > Right now, I had redefined CDVFileTranfer for our needs and added just after userAgent definition: > if(userAgent) { > [req setValue: userAgent forHTTPHeaderField:@"User-Agent"]; > } > > NSMutableDictionary* headers = [params objectForKey:@"headers"]; > NSEnumerator *enumerator = [headers keyEnumerator]; > id key; > id val; > NSString *nkey; > > while (nkey = [enumerator nextObject]) { > val = [headers objectForKey:nkey]; > if(!val || val == [NSNull null]) { > continue; > } > // if it responds to stringValue selector (eg NSNumber) get the NSString > if ([val respondsToSelector:@selector(stringValue)]) { > val = [val stringValue]; > } > // finally, check whether it is a NSString (for dataUsingEncoding selector below) > if (![val isKindOfClass:[NSString class]]) { > continue; > } > > //if ([key respondsToSelector:@selector(stringValue)]) { > [req setValue:val forHTTPHeaderField:nkey]; > //} > } > If you can include this code or similar one into future version of Cordova it will be awesome. > Thanks, -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira