Document Id and Rev in response headers #32

wants to merge 3 commits into from

4 participants


This patch adds the X-Couch-Id and X-Couch-Rev headers to responses, so that a custom default_handler can act on DB changes (e.g. create tasks).

We have a custom default_handler that creates Celery tasks via a Python process. It wraps the couch_httpd_d:handle_request/1 function, looks at the response, then creates some tasks. What it needs is the document Id and Rev for each PUT/POST/DELETE request, but those are not available from the Response on that level (the response body is sent to the socket inside the black box somewhere). The headers are available. So we decided to add the Id and Rev to the JSON responses and also the update function as X-Couch-Id and X-Couch-Rev. When using an update function, the rev is available though "X-Couch-Update-NewRev", so only the Id has been added.

We have a large amount of small databases (potentially thousands), so it is not practical to listen to changes on every DB.

If there is another recommendation to achieve this without patching, please suggest an alternative.


You should be able to leverage the Etag response header instead of adding X-Couch-Rev, right?


Ah yes, that's true. Just need the ID then


Can you add a quick test for this? I’m happy to merge this then.

dch commented Nov 1, 2012

@bjnortier we are going to branch for 1.3.0 on Wednesday 5th. Are you able to add a test so we can get your patch in? Thanks for your contribution!


Will do asap


Test added, I hope this conforms


Committed, thanks! :)

Can you close the PR for us? Thanks!



@bjnortier bjnortier closed this Nov 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment