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-51 API: FileTransfer - Support PUT Method
Date Mon, 16 Nov 2015 09:14:55 GMT
Repository: cordova-labs
Updated Branches:
  refs/heads/cordova-filetransfer dafe2863c -> 2361a3dc6


CB-51 API: FileTransfer - Support PUT Method

Replaces tabs with whitespaces


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

Branch: refs/heads/cordova-filetransfer
Commit: 2361a3dc6c1d414fbd835797ceff5c3b38629a56
Parents: dafe286
Author: daserge <v-seshak@microsoft.com>
Authored: Wed Oct 28 15:33:26 2015 +0300
Committer: daserge <v-seshak@microsoft.com>
Committed: Wed Oct 28 15:33:26 2015 +0300

----------------------------------------------------------------------
 server.js | 148 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 74 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/2361a3dc/server.js
----------------------------------------------------------------------
diff --git a/server.js b/server.js
index 12b3ae3..dbb07e3 100644
--- a/server.js
+++ b/server.js
@@ -1,75 +1,75 @@
-var formidable = require('formidable'),
-    http = require('http'),
-    util = require('util'),
-    port = process.env.PORT || 5000;
-    stringify = require('json-stringify-safe');
-
-http.createServer(function (req, res) {
-    // Set CORS headers
-    res.setHeader('Access-Control-Allow-Origin', '*');
-
-	var basic_auth_username = "cordova_user";
-	var basic_auth_password = "cordova_password";
-	
-	var header = req.headers['authorization']||'',      // get the header
-      token = header.split(/\s+/).pop()||'',            // and the encoded auth token
-      auth = new Buffer(token, 'base64').toString(),    // convert from base64
-      parts = auth.split(/:/),                          // split on colon
-      username = parts[0],
-      password = parts[1];
-
-    if (req.url === "/download_basic_auth") {
-		if (username != basic_auth_username && password != basic_auth_password) {
-			res.writeHead(401, {'Content-Type': 'text/plain'});
-			res.end("401\n");    
-		} else {
-	        res.writeHead(200, {'Content-Type': 'text/plain'});
-	        res.write("User-Agent: *\n");
-	        res.end("Disallow: /\n");
-		}
-    } else if (req.url === "/robots.txt") {
-        res.writeHead(200, {'Content-Type': 'text/plain'});
-        res.write("User-Agent: *\n");
-        res.end("Disallow: /\n");
-    } else if (req.url === "/") {
-		res.writeHead(200, {'Content-Type': 'text/plain'});
-		res.end("Hello!\n");    
-	} else if (req.url == '/upload' && 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}));
-            
-            res.write(stringify({fields: fields, files: files}));
-            console.log
-            res.end("\n");
-        });
-	} else if (req.url == '/upload_basic_auth' && req.method.toLowerCase() == 'post')
{
-		if (username != basic_auth_username && password != basic_auth_password) {
-			res.writeHead(401, {'Content-Type': 'text/plain'});
-			res.end("401\n");    
-		} else {
-	        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}));
-
-	            res.write(stringify({fields: fields, files: files}));
-	            console.log
-	            res.end("\n");
-	        });
-		}
-	} else if (req.url.match(/\d{3}/)) { 
-	    var matches = req.url.match(/\d{3}/);
-	    status = matches[0];
-		res.writeHead(status, {'Content-Type': 'text/plain'});
-		res.end("You requested a " + status + "\n");                
-    } else {
-		res.writeHead(404, {'Content-Type': 'text/plain'});
-		res.end("404\n");    
-    }
-    
-    console.log(req.connection.remoteAddress + " " + req.method + " " + req.url + " " + res.statusCode
+ " " + req.headers['user-agent']);
-    
-}).listen(port, '0.0.0.0');
+var formidable = require('formidable'),
+    http = require('http'),
+    util = require('util'),
+    port = process.env.PORT || 5000;
+    stringify = require('json-stringify-safe');
+
+http.createServer(function (req, res) {
+    // Set CORS headers
+    res.setHeader('Access-Control-Allow-Origin', '*');
+
+    var basic_auth_username = "cordova_user";
+    var basic_auth_password = "cordova_password";
+
+    var header = req.headers['authorization']||'',        // get the header
+        token = header.split(/\s+/).pop()||'',            // and the encoded auth token
+        auth = new Buffer(token, 'base64').toString(),    // convert from base64
+        parts = auth.split(/:/),                          // split on colon
+        username = parts[0],
+        password = parts[1];
+
+    if (req.url === "/download_basic_auth") {
+        if (username != basic_auth_username && password != basic_auth_password) {
+            res.writeHead(401, {'Content-Type': 'text/plain'});
+            res.end("401\n");
+        } else {
+            res.writeHead(200, {'Content-Type': 'text/plain'});
+            res.write("User-Agent: *\n");
+            res.end("Disallow: /\n");
+        }
+    } else if (req.url === "/robots.txt") {
+        res.writeHead(200, {'Content-Type': 'text/plain'});
+        res.write("User-Agent: *\n");
+        res.end("Disallow: /\n");
+    } else if (req.url === "/") {
+        res.writeHead(200, {'Content-Type': 'text/plain'});
+        res.end("Hello!\n");
+    } else if (req.url == '/upload' && (req.method.toLowerCase() == 'post' || req.method.toLowerCase()
== 'put')) {
+        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}));
+
+            res.write(stringify({fields: fields, files: files}));
+            console.log
+            res.end("\n");
+        });
+    } else if (req.url == '/upload_basic_auth' && req.method.toLowerCase() == 'post')
{
+        if (username != basic_auth_username && password != basic_auth_password) {
+            res.writeHead(401, {'Content-Type': 'text/plain'});
+            res.end("401\n");
+        } else {
+            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}));
+
+                res.write(stringify({fields: fields, files: files}));
+                console.log
+                res.end("\n");
+            });
+        }
+    } else if (req.url.match(/\d{3}/)) {
+        var matches = req.url.match(/\d{3}/);
+        status = matches[0];
+        res.writeHead(status, {'Content-Type': 'text/plain'});
+        res.end("You requested a " + status + "\n");
+    } else {
+        res.writeHead(404, {'Content-Type': 'text/plain'});
+        res.end("404\n");
+    }
+
+    console.log(req.connection.remoteAddress + " " + req.method + " " + req.url + " " + res.statusCode
+ " " + req.headers['user-agent']);
+
+}).listen(port, '0.0.0.0');
 console.log('Server running on ' + port);
\ No newline at end of file


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


Mime
View raw message