[the-board] [util] Support form data on HTTP api calls



commit a97c96ee3788d65c5d6b7b820e15bab1190cfbb8
Author: Lucas Rocha <lucasr gnome org>
Date:   Fri Nov 26 00:51:45 2010 +0000

    [util] Support form data on HTTP api calls

 src/js/util/http.js |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/js/util/http.js b/src/js/util/http.js
index 92b1eb6..a5d87a3 100644
--- a/src/js/util/http.js
+++ b/src/js/util/http.js
@@ -1,8 +1,10 @@
 // standard imports
+const ByteArray = imports.byteArray;
 const Lang = imports.lang;
 
 // gi imports
 const Soup = imports.gi.Soup;
+const Tb = imports.gi.Tb;
 
 // util imports
 const JSON = imports.util.json;
@@ -24,6 +26,12 @@ function exportObject(port, iface, object) {
             Lang.copyProperties(query, args);
         }
 
+        if (msg.requestHeaders.get_content_type(null) == "multipart/form-data") {
+            let [params, filename, contentType, buffer] =
+                Soup.form_decode_multipart(msg, "file");
+            args.fileData = Tb.soup_buffer_get_data(buffer);
+        }
+
         let result = object[method.name].apply(object, [args]);
 
         if (result) {



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