You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2018/10/02 17:37:30 UTC

[couchdb] branch master updated (abb2a86 -> 7b48b63)

This is an automated email from the ASF dual-hosted git repository.

wohali pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    from abb2a86  Make sure to start per-node rexi servers right away
     new 4267e1f  js rewrite send body
     new 7b48b63  add test for 1612

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/chttpd/src/chttpd_rewrite.erl   |  9 ++++++++-
 test/javascript/tests/rewrite_js.js | 16 ++++++++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)


[couchdb] 02/02: add test for 1612

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 7b48b63a7044f30b7f133f4b8001c1906a6f3136
Author: ermouth <er...@gmail.com>
AuthorDate: Fri Sep 28 03:10:29 2018 +0300

    add test for 1612
---
 test/javascript/tests/rewrite_js.js | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/test/javascript/tests/rewrite_js.js b/test/javascript/tests/rewrite_js.js
index 9893127..22de6c9 100644
--- a/test/javascript/tests/rewrite_js.js
+++ b/test/javascript/tests/rewrite_js.js
@@ -100,9 +100,12 @@ couchTests.rewrite = function(debug) {
             return {path: '_list/simpleForm/complexView2',
                     query: {key: JSON.stringify({"c": 1})}};
         }
-        if (req.path.slice(4).join('/') === 'simpleForm/complexView4') {
-            return {path: '_list/simpleForm/complexView2',
-                    query: {key: JSON.stringify({"c": 1})}};
+        if (req.path.slice(4).join('/') === 'simpleForm/sendBody1') {
+            return {path:   '_list/simpleForm/complexView2',
+                    method: 'POST',
+                    query:  {limit: '1'},
+                    headers:{'Content-type':'application/json'},
+                    body:  JSON.stringify( {keys: [{"c": 1}]} )};
         }
         if (req.path.slice(4).join('/') === '/') {
             return {path: '_view/basicView'};
@@ -283,6 +286,11 @@ couchTests.rewrite = function(debug) {
     T(xhr.status == 200, "with query params");
     T(/Value: doc 5/.test(xhr.responseText));
 
+    // COUCHDB-1612 - send body rewriting get to post
+    xhr = CouchDB.request("GET", "/"+dbName+"/_design/test/_rewrite/simpleForm/sendBody1");
+    T(xhr.status == 200, "get->post rewrite failed:\n"+xhr.responseText);
+    T(/Value: doc 5 LineNo: 1/.test(xhr.responseText), "get->post rewrite responded wrong:\n"+xhr.responseText);
+
     // COUCHDB-2031 - path normalization versus qs params
     xhr = CouchDB.request("GET", "/"+dbName+"/_design/test/_rewrite/db/_design/test?meta=true");
     T(xhr.status == 200, "path normalization works with qs params");
@@ -340,4 +348,4 @@ couchTests.rewrite = function(debug) {
     // cleanup
     db.deleteDb();
   }
-}
+}
\ No newline at end of file


[couchdb] 01/02: js rewrite send body

Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wohali pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4267e1ff805e6f5719f770c780874b3d8ba78d9a
Author: ermouth <er...@gmail.com>
AuthorDate: Fri Sep 21 20:52:30 2018 +0300

    js rewrite send body
    
    Fixes #1612
---
 src/chttpd/src/chttpd_rewrite.erl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/chttpd/src/chttpd_rewrite.erl b/src/chttpd/src/chttpd_rewrite.erl
index 039390e..24a4824 100644
--- a/src/chttpd/src/chttpd_rewrite.erl
+++ b/src/chttpd/src/chttpd_rewrite.erl
@@ -64,7 +64,14 @@ do_rewrite(#httpd{mochi_req=MochiReq}=Req, {Props}=Rewrite) when is_list(Props)
                                                Path,
                                                MochiReq:get(version),
                                                Headers),
-            NewMochiReq:cleanup(),
+            Body = case couch_util:get_value(<<"body">>, Props) of
+                undefined -> erlang:get(mochiweb_request_body);
+                B -> B
+            end,
+            case Body of
+                undefined -> NewMochiReq:cleanup();
+                _ -> erlang:put(mochiweb_request_body, Body)
+            end,
             couch_log:debug("rewrite to ~p", [Path]),
             chttpd:handle_request_int(NewMochiReq);
         Code ->