Ronald Partridge created CB-1753:
------------------------------------
Summary: Some web servers generate a 503 error with
FileTransfer.upload
Key: CB-1753
URL: https://issues.apache.org/jira/browse/CB-1753
Project: Apache Cordova
Issue Type: Bug
Components: Android
Affects Versions: 1.9.0
Environment: Client: Galaxy Nexus running 4.0.3
Server: Nginx/Varnish/PHP 5.3.x (I can get the software versions from the admin)
Reporter: Ronald Partridge
Assignee: Joe Bowser
Fix For: Master
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<EF><8A>P9)^B^@6^@^@^@6^@^@^@^@^@^L^G<AC><C8>^@PV<8E>^A^@E^@^@(<E1>e@^@@^F<DE>ESC^_[&c<88><B2>^@P<FF><BD>%&<9C><A5><AF>WĘP^P^Y
<E6>^^@^@o<EF><8A>P<93>,^B^@<D9>^D^@
^@<D9>^D^@^@^@^@^L^G<AC><C8>^@PV<8E>^A^@E^@^D<CB><E1>f@^@@^F<DA>:<AC>ESC^_[&c<88><B2>^@P<FF><BD>%&<9C><A5><AF>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<EF><8A>P;^F^A^@6^@^@^@6^@^@^@^@^@^L^G<AC><C8>^@PV<8E>^A^@E^@^@(}1@^@@^FC^S<AC>ESC^_[&c<88><B2>^@P<F7><8F><A1><F9><EB><CF>^^^_<C1>P^P^Y
^X`^@^@4<EF><8A>P<F7>^K^A^@
<9A>^E^@^@<9A>^E^@^@^@PV<8E>^A:^@^U<FA>~<E0>^Z^H^@E^@^E<8C><D7>C@^@)^F<FA><9C>&c<88><B2><AC>ESC^_[<F7><8F>^@P^^^_<C1><A1><F9><EB><CF>P^P<FF><FF><F9><A6>^@^@--*****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
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira