[Groonga-commit] droonga/express-droonga at d65e7a0 [master] Recenve post data correctly

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Oct 4 19:06:50 JST 2013


YUKI Hiroshi	2013-10-04 19:06:50 +0900 (Fri, 04 Oct 2013)

  New Revision: d65e7a061fb76b47219ad886a14a20507d9559ef
  https://github.com/droonga/express-droonga/commit/d65e7a061fb76b47219ad886a14a20507d9559ef

  Message:
    Recenve post data correctly

  Modified files:
    lib/adapter/api/droonga.js
    test/adapter/rest.test.js

  Modified: lib/adapter/api/droonga.js (+9 -8)
===================================================================
--- lib/adapter/api/droonga.js    2013-10-04 18:50:31 +0900 (4169625)
+++ lib/adapter/api/droonga.js    2013-10-04 19:06:50 +0900 (5af2e04)
@@ -7,15 +7,16 @@ module.exports = {
     path: '/droonga/:messageType',
     onRequest: function(request, connection) {
       var messageType = request.params.messageType;
-
-      var body = request.body;
-      if (typeof body == 'string')
+      var body = '';
+      request.on('data', function(chunk) {
+        body += chunk;
+      });
+      request.on('end', function() {
         body = JSON.parse(body);
-
-      body.timeout = body.timeout || 1000;
-      body.type = body.type || 'droonga-' + messageType;
-
-      connection.emit(messageType, body);
+        body.timeout = body.timeout || 1000;
+        body.type = body.type || 'droonga-' + messageType;
+        connection.emit(messageType, body);
+      });
     }
   })
 };

  Modified: test/adapter/rest.test.js (+0 -1)
===================================================================
--- test/adapter/rest.test.js    2013-10-04 18:50:31 +0900 (efff37b)
+++ test/adapter/rest.test.js    2013-10-04 19:06:50 +0900 (c99a52f)
@@ -225,7 +225,6 @@ suite('HTTP Adapter', function() {
       var receiverCallback = {};
       var connection = utils.createStubbedBackendConnection();
       var application = express();
-      application.use(express.bodyParser());
       httpAdapter.register(application, {
         prefix:     '',
         connection: connection
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index