You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
apache / couchdb Public
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS rewrite, returning should send body to the rewritten endpoint.
The body field of rewrite fn returned obj is in some cases dropped. If source request was POST/PUT, the rewritten requests hangs, or, if source request was GET-like, bad_request error is sent as response.
< "_id": "_design/n", "rewrites": "function (r) ,\n\t\tbody:JSON.stringify()\n\t>\n>" >
The issue is caused by cleaning-up rewritten request prematurely here:
https://github.com/apache/couchdb/blob/master/src/chttpd/src/chttpd_rewrite.erl#L67.
It should only be cleaned if we have no body to send.
That line (L67) should be replaced with this code:
Body = case couch_util:get_value(>, Props) of undefined -> erlang:get(mochiweb_request_body); B -> B end, case Body of undefined -> NewMochiReq:cleanup(); _ -> erlang:put(mochiweb_request_body, Body) end,
It seems to fix issue completely.
The text was updated successfully, but these errors were encountered: