iilyak commented on pull request #3277:
URL: https://github.com/apache/couchdb/pull/3277#issuecomment-730397702


   > Could you address my comment about the change of the format of req_body in 
this PR versus all the current uses of req_body?
   
   The purpose of https://github.com/apache/couchdb/pull/2991 is to allow 
injecting modified body from EPI plugins. Without this change it is quite hard 
to modify body because the one would need to either:
   - find a way how to override HTTP headers in Mochiweb to change 
"Content-Encoding" to identity (there is no official way).
   - convert JSON object into binary and optionally gzip it if 
`"Content-Encoding"` header contains `gzip` (which would add an overhead for 
big requests).
   
   It also let us to remove process dictionary use in 
`chttpd_misc:handle_replicate_req` (leaky abstraction).
   
   The change allows EPI users to easily modify body. 
   - `Req#httpd{req_body={Props}}` - for JSON
   - `Req#httpd{req_body=<<"non-JSON body">>}` - for non JSON
   
   The `json_body/1` always returns JSON obj:
   - when `req_body` is undefined we decompress and decode JSON from Mochiweb
   - when `req_body` is set we return it as is (we assume it is set as 
`#httpd{req_body={Props}}` i.e. contains JSON obj, this is a responsibility of 
EPI plugin author).
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to