[the-board/wip/http-api] more



commit 68a28986106d83ea1b1ee8ae9aff0ffb0538aa6b
Author: Lucas Rocha <lucasr gnome org>
Date:   Tue Nov 23 18:23:38 2010 +0000

    more

 src/js/util/http.js |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/src/js/util/http.js b/src/js/util/http.js
index 66ed373..a66ffbb 100644
--- a/src/js/util/http.js
+++ b/src/js/util/http.js
@@ -4,6 +4,9 @@ const Lang = imports.lang;
 // gi imports
 const Soup = imports.gi.Soup;
 
+// util imports
+const JSON = imports.util.json;
+
 function exportObject(port, iface, object) {
     log('Http: exporting object on port ' + port);
 
@@ -21,7 +24,16 @@ function exportObject(port, iface, object) {
             Lang.copyProperties(query, args);
         }
 
-        object[method.name].apply(object, [args]);
+        let result = object[method.name].apply(object, [args]);
+
+        if (result) {
+            let resultStr = JSON.JSON.stringify(result, null, 4);
+
+            msg.set_response("text/plain",
+                             Soup.MemoryUse.STATIC,
+                             resultStr,
+                             resultStr.length);
+        }
 
         msg.set_status(200);
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]