Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E8F69D5DA for ; Thu, 6 Dec 2012 02:49:23 +0000 (UTC) Received: (qmail 91769 invoked by uid 500); 6 Dec 2012 02:49:23 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 91738 invoked by uid 500); 6 Dec 2012 02:49:23 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 91700 invoked by uid 99); 6 Dec 2012 02:49:22 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2012 02:49:22 +0000 Received: from localhost (HELO [192.168.10.100]) (127.0.0.1) (smtp-auth username bdube, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2012 02:49:22 +0000 Message-ID: <50C007B1.6000902@apache.org> Date: Wed, 05 Dec 2012 18:49:21 -0800 From: Brian M Dube User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.10) Gecko/20121028 Icedove/10.0.10 MIME-Version: 1.0 To: dev@cordova.apache.org Subject: Re: Android Cordova FileTransfer.upload generates 503 errors with some web servers. References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 10/30/2012 07:53 AM, Simon MacDonald wrote: > I would have loved to have used the Apache HttpClient package but we are > trying to stay away from external dependencies. Apache HttpClient is available to applications as part of the Android platform, isn't it? Perhaps I've misunderstood. org.apache.cordova.HttpHandler [1] makes use of HttpClient, but HttpHandler itself doesn't appear to be referenced by any other Cordova code. I'd be happy to work on a pull request if it is in fact available without adding a dependency. -Brian [1] https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=blob;f=framework/src/org/apache/cordova/HttpHandler.java > When you set chunkedMode to false I know that the transfer worked as per > your comment on JIRA. I will update the docs to mention Nginx servers. > > Simon Mac Donald > http://hi.im/simonmacdonald > > > On Mon, Oct 29, 2012 at 2:56 PM, Ronald Partridge > wrote: > >> See: >> >> https://github.com/apache/incubator-cordova-android/blob/master/framework/src/org/apache/cordova/FileTransfer.java >> private void upload(final String source, final String target, JSONArray >> args >> , CallbackContext callbackContext) >> >> Cordova Android may have a bug with the way files are being sent. The >> Android source code appears to use the built in java HttpURLConnection and >> the developer who wrote the functionality decided to write the logic to >> assemble the post data to be transfered. I examined two different post >> dumps >> being sent to a web server running Nginx and Varnish. Notice how the >> headers are different between *iOS *and *Android*. >> I would suggest using >> >> http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html >> >> Here are the two post dumps: >> * >> Android:* >> >> POST /service/claim/photo/75?api_key=123ab >> c HTTP/1.1 >> Connection: Keep-Alive >> Content-Type: multipart/form-data;boundary=***** >> User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.1.1; Nexus S Build/JRO03E) >> Host: sit.service.app.mydomain.ca >> Accept-Encoding: gzip >> Transfer-Encoding: chunked >> >> o<8A>P9)^B^@6^@^@^@6^@^@^@^@^@^L^G^@PV<8E>^A^@E^@^@(e@ >> ^@@^FESC^_[&c<88>^@P%&<9C>WĘP^P^Y >> ^^@^@o<8A>P<93>,^B^@^D^@ >> ^@^D^@^@^@^@^L^G^@PV<8E>^A^@E^@^Df@^@@^ >> F:ESC^_[&c<88>^@P%&<9C>WĘP^X^Y ^?I^@^@HTTP/1.1 >> 503 Service Unavailable >> Server: Varnish >> Content-Type: text/html; charset=utf-8 >> Content-Length: 932 >> Accept-Ranges: bytes >> Date: Fri, 26 Oct 2012 20:15:43 GMT >> X-Varnish: 409357173 >> Age: 0 >> Via: 1.1 varnish >> Connection: close >> X-Cache: MISS >> >> >> *iOS*: >> >> POST /service/claim/photo/73?api_key=123abc HTTP/1.1 >> >> Host: sit.service.app.mydomain.ca >> User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) >> AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 >> Content-Length: 139038 >> Accept: */* >> Content-Type: multipart/form-data; boundary=*****org.apache. >> cordova.formBoundary >> X-Requested-With: XMLHttpRequest >> >> Accept-Language: en-us >> Accept-Encoding: gzip, deflate >> Connection: keep-alive >> >> 4<8A>P;^F^A^@6^@^@^@6^@^@^@^@^@^L^G^@PV<8E>^A^@E^@^@(}1@ >> ^@@^FC^SESC^_[&c<88>^@P<8F>^^^_P^P^Y >> ^X`^@^@4<8A>P^K^A^@ >> <9A>^E^@^@<9A>^E^@^@^@PV<8E>^A:^@^U~^Z^H^@E^@^E<8C>C@ >> ^@)^F<9C>&c<88>ESC^_[<8F>^@P^^^_< >> >> A1>P^P^@^@--*****org.apache.cordova.formBoundary >> Content-Disposition: form-data; name="description" >> >> Photo >> --*****org.apache.cordova.formBoundary >> Content-Disposition: form-data; name="userfile"; >> filename="cdv_photo_002.jpg" >> Content-Type: image/jpeg >> Content-Length: 138722 >> >> >> >> < >> http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html >>> >> >