cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dase...@apache.org
Subject cordova-labs git commit: CB-9840 Fallback file-transfer uploadResponse encoding to latin1 in case not encoded with UTF-8 on iOS
Date Tue, 08 Dec 2015 09:05:01 GMT
Repository: cordova-labs
Updated Branches:
  refs/heads/cordova-filetransfer cc780555b -> 9f5e1a2e1


CB-9840 Fallback file-transfer uploadResponse encoding to latin1 in case not encoded with
UTF-8 on iOS

Adds non-utf endpoints for the correspoding tests: filetransfer.spec.36 and 37. Implemented
using node-iconv.


Project: http://git-wip-us.apache.org/repos/asf/cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-labs/commit/9f5e1a2e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-labs/tree/9f5e1a2e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-labs/diff/9f5e1a2e

Branch: refs/heads/cordova-filetransfer
Commit: 9f5e1a2e18a82891ce3b255fbee72f87cbc9dc3c
Parents: cc78055
Author: daserge <v-seshak@microsoft.com>
Authored: Fri Dec 4 15:20:59 2015 +0300
Committer: daserge <v-seshak@microsoft.com>
Committed: Fri Dec 4 15:22:03 2015 +0300

----------------------------------------------------------------------
 package.json |  5 +++--
 server.js    | 23 +++++++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/9f5e1a2e/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 657a838..25dbdfc 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,8 @@
     "node": ">=0.10.0"
   },
   "dependencies": {
-    "json-stringify-safe": "5.0.0",
-    "formidable": "1.0.x"
+    "formidable": "1.0.x",
+    "iconv": "2.1.x",
+    "json-stringify-safe": "5.0.0"
   }
 }

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/9f5e1a2e/server.js
----------------------------------------------------------------------
diff --git a/server.js b/server.js
index 88d6b15..c663a71 100644
--- a/server.js
+++ b/server.js
@@ -6,6 +6,11 @@ var formidable = require('formidable'),
 
 var DIRECT_UPLOAD_LIMIT = 32; // bytes
 
+// convert from UTF-8 to ISO-8859-1
+var LATIN1_SYMBOLS = '¥§©ÆÖÑøøø¼';
+var Iconv  = require('iconv').Iconv;
+var iconv = new Iconv('UTF-8', 'ISO-8859-1');
+
 http.createServer(function (req, res) {
     // Set CORS headers
     res.setHeader('Access-Control-Allow-Origin', '*');
@@ -33,6 +38,13 @@ http.createServer(function (req, res) {
         res.writeHead(200, {'Content-Type': 'text/plain'});
         res.write("User-Agent: *\n");
         res.end("Disallow: /\n");
+    } else if (req.url === "/download_non_utf") {
+        res.writeHead(200, {'Content-Type': 'text/plain'});
+        res.write("User-Agent: *\n");
+
+        res.write(iconv.convert(LATIN1_SYMBOLS));
+
+        res.end("Disallow: /\n");
     } else if (req.url === "/") {
         res.writeHead(200, {'Content-Type': 'text/plain'});
         res.end("Hello!\n");
@@ -78,6 +90,17 @@ http.createServer(function (req, res) {
                 res.end("\n");
             });
         }
+    } else if (req.url == '/upload_non_utf' && req.method.toLowerCase() == 'post')
{
+        var form = new formidable.IncomingForm();
+        form.parse(req, function(err, fields, files) {
+            res.writeHead(200, {'content-type': 'text/plain'});
+            console.log(stringify({fields: fields, files: files}));
+
+            var buffer = iconv.convert(stringify({fields: fields, files: files, latin1Symbols:
LATIN1_SYMBOLS}));
+            res.write(buffer);
+
+            res.end("\n");
+        });
     } else if (req.url.match(/\d{3}/)) {
         var matches = req.url.match(/\d{3}/);
         status = matches[0];


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message