Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-1447

X-Couch-Update-NewRev header is missed if custom headers are specified in response of _update handler

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2, 1.3
    • Fix Version/s: 2.0.0
    • Labels:
      None
    • Environment:

      Apache CouchDB 1.3.0a-a2bea1f-git
      Apache CouchDB 1.2.0a-94e72e7-git

      Description

      {
      "_id": "_design/dump",
      "_rev": "1-74b49af793bd5ce090712f638c3c920e",
      "updates": {
      "doc": "function(doc, req){ return [doc, {headers:

      {'Content-Type': 'text/html'}

      , 'body': '<h1>test</h1>'}]}"
      }
      }

      curl -v -X PUT http://localhost:5984/app%2fdefault/_design/dump/_update/doc/foo

      • About to connect() to localhost port 5984 (#0)
      • Trying 127.0.0.1...
      • connected
      • Connected to localhost (127.0.0.1) port 5984 (#0)
        > PUT /app%2fdefault/_design/dump/_update/doc/foo HTTP/1.1
        > User-Agent: curl/7.24.0 (x86_64-pc-linux-gnu) libcurl/7.24.0 GnuTLS/2.10.5 zlib/1.2.6
        > Host: localhost:5984
        > Accept: /
        >
        < HTTP/1.1 201 Created
        < Server: CouchDB/1.3.0a-a2bea1f-git (Erlang OTP/R15B)
        < Date: Mon, 19 Mar 2012 01:45:20 GMT
        < Content-Type: text/html
        < Content-Length: 13
        <
      • Connection #0 to host localhost left intact
        <h1>test</h1>* Closing connection #0

      {
      "_id": "_design/dump",
      "_rev": "2-f1c20db4fb28846399ab1cecaa9d2f28",
      "updates": {
      "doc": "function(doc, req){ return [doc,

      {'body': '<h1>test</h1>'}

      ]}"
      }
      }

      curl -v -X PUT http://localhost:5984/app%2fdefault/_design/dump/_update/doc/foo

      • About to connect() to localhost port 5984 (#0)
      • Trying 127.0.0.1...
      • connected
      • Connected to localhost (127.0.0.1) port 5984 (#0)
        > PUT /app%2fdefault/_design/dump/_update/doc/foo HTTP/1.1
        > User-Agent: curl/7.24.0 (x86_64-pc-linux-gnu) libcurl/7.24.0 GnuTLS/2.10.5 zlib/1.2.6
        > Host: localhost:5984
        > Accept: /
        >
        < HTTP/1.1 201 Created
        < X-Couch-Update-NewRev: 4-89c1c79a98fc269e474eb64d999a2049
        < Server: CouchDB/1.3.0a-a2bea1f-git (Erlang OTP/R15B)
        < Date: Mon, 19 Mar 2012 01:46:43 GMT
        < Content-Type: text/html; charset=utf-8
        < Content-Length: 13
        <
      • Connection #0 to host localhost left intact
        <h1>test</h1>* Closing connection #0

        Issue Links

          Activity

          Hide
          rnewson Robert Newson added a comment -

          The relevant section of code is here (couch_mrview_show.erl);

          {[

          {<<"code">>, 201}

          ,
          {<<"headers">>, {[

          {<<"X-Couch-Update-NewRev">>, NewRevStr}

          ]}}

          JsonResp0]};

          If JsonResp0 includes a headers entry, then the X-Couch-Update-NewRev header is lost (only one of the <<"headers">> items is found, they are not merged).

          Should they be merged or should sending "headers" from a show function suppress this field?

          I think the former but would like some opinions.

          Show
          rnewson Robert Newson added a comment - The relevant section of code is here (couch_mrview_show.erl); {[ {<<"code">>, 201} , {<<"headers">>, {[ {<<"X-Couch-Update-NewRev">>, NewRevStr} ]}} JsonResp0]}; If JsonResp0 includes a headers entry, then the X-Couch-Update-NewRev header is lost (only one of the <<"headers">> items is found, they are not merged). Should they be merged or should sending "headers" from a show function suppress this field? I think the former but would like some opinions.
          Hide
          benoitc Benoit Chesneau added a comment -

          Since this is the only way to get the new revision, I think we should merge the headers here. It's useful.

          In the original code I don't remember we had the possibility to override headers in an _update function, that's why it's missing.

          Show
          benoitc Benoit Chesneau added a comment - Since this is the only way to get the new revision, I think we should merge the headers here. It's useful. In the original code I don't remember we had the possibility to override headers in an _update function, that's why it's missing.
          Hide
          dch Dave Cottlehuber added a comment -

          +1 for merging.

          Show
          dch Dave Cottlehuber added a comment - +1 for merging.
          Hide
          bigbluehat BigBlueHat added a comment -

          Just ran into this problem...

          +1 to merging the X-Couch-Update-NewRev into any custom headers.

          Show
          bigbluehat BigBlueHat added a comment - Just ran into this problem... +1 to merging the X-Couch-Update-NewRev into any custom headers.
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user kxepal opened a pull request:

          https://github.com/apache/couchdb-couch-mrview/pull/34

          Merge default update response headers with custom ones

          COUCHDB-1447

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/kxepal/couchdb-couch-mrview 1447-merge-update-headers

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/couchdb-couch-mrview/pull/34.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #34


          commit a84a065bf7bdcfc424c8e71590c4ff6af21d6df8
          Author: Alexander Shorin <kxepal@apache.org>
          Date: 2015-10-22T20:21:17Z

          Merge default update response headers with custom ones

          COUCHDB-1447

          commit ac7c5c28ae6a884bf9794b8174169b062b35cd25
          Author: Alexander Shorin <kxepal@apache.org>
          Date: 2015-10-22T20:22:58Z

          Reduce duplicated code


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user kxepal opened a pull request: https://github.com/apache/couchdb-couch-mrview/pull/34 Merge default update response headers with custom ones COUCHDB-1447 You can merge this pull request into a Git repository by running: $ git pull https://github.com/kxepal/couchdb-couch-mrview 1447-merge-update-headers Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-couch-mrview/pull/34.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #34 commit a84a065bf7bdcfc424c8e71590c4ff6af21d6df8 Author: Alexander Shorin <kxepal@apache.org> Date: 2015-10-22T20:21:17Z Merge default update response headers with custom ones COUCHDB-1447 commit ac7c5c28ae6a884bf9794b8174169b062b35cd25 Author: Alexander Shorin <kxepal@apache.org> Date: 2015-10-22T20:22:58Z Reduce duplicated code
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 0334f690c5ccc16ea0284d9c2f2b58c77f1fc2b9 in couchdb-couch-mrview's branch refs/heads/master from Alexander Shorin
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb-couch-mrview.git;h=0334f69 ]

          Merge default update response headers with custom ones

          COUCHDB-1447

          Show
          jira-bot ASF subversion and git services added a comment - Commit 0334f690c5ccc16ea0284d9c2f2b58c77f1fc2b9 in couchdb-couch-mrview's branch refs/heads/master from Alexander Shorin [ https://git-wip-us.apache.org/repos/asf?p=couchdb-couch-mrview.git;h=0334f69 ] Merge default update response headers with custom ones COUCHDB-1447
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/couchdb-couch-mrview/pull/34

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/couchdb-couch-mrview/pull/34
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit e796a95ea6a4af615054bf476d902b86b7b6c4f2 in couchdb's branch refs/heads/master from Alexander Shorin
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=e796a95 ]

          COUCHDB-1447

          Show
          jira-bot ASF subversion and git services added a comment - Commit e796a95ea6a4af615054bf476d902b86b7b6c4f2 in couchdb's branch refs/heads/master from Alexander Shorin [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=e796a95 ] COUCHDB-1447
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit e796a95ea6a4af615054bf476d902b86b7b6c4f2 in couchdb's branch refs/heads/2876-js-tests from Alexander Shorin
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=e796a95 ]

          COUCHDB-1447

          Show
          jira-bot ASF subversion and git services added a comment - Commit e796a95ea6a4af615054bf476d902b86b7b6c4f2 in couchdb's branch refs/heads/2876-js-tests from Alexander Shorin [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=e796a95 ] COUCHDB-1447
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user rnewson opened a pull request:

          https://github.com/apache/couchdb-chttpd/pull/151

          Merge default update response headers with custom ones

          This was not ported to chttpd and so wasn't really fixed in 2.0

          COUCHDB-1447

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/cloudant/couchdb-chttpd 1447-merge-headers-2.0

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/couchdb-chttpd/pull/151.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #151



          Show
          githubbot ASF GitHub Bot added a comment - GitHub user rnewson opened a pull request: https://github.com/apache/couchdb-chttpd/pull/151 Merge default update response headers with custom ones This was not ported to chttpd and so wasn't really fixed in 2.0 COUCHDB-1447 You can merge this pull request into a Git repository by running: $ git pull https://github.com/cloudant/couchdb-chttpd 1447-merge-headers-2.0 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-chttpd/pull/151.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #151
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 7bfd253c676800b1dfa85f003217197bd6761360 in couchdb-chttpd's branch refs/heads/master from Robert Newson
          [ https://git-wip-us.apache.org/repos/asf?p=couchdb-chttpd.git;h=7bfd253 ]

          Merge default update response headers with custom ones

          This was not ported to chttpd and so wasn't really fixed in 2.0

          COUCHDB-1447

          Show
          jira-bot ASF subversion and git services added a comment - Commit 7bfd253c676800b1dfa85f003217197bd6761360 in couchdb-chttpd's branch refs/heads/master from Robert Newson [ https://git-wip-us.apache.org/repos/asf?p=couchdb-chttpd.git;h=7bfd253 ] Merge default update response headers with custom ones This was not ported to chttpd and so wasn't really fixed in 2.0 COUCHDB-1447
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/couchdb-chttpd/pull/151

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/couchdb-chttpd/pull/151

            People

            • Assignee:
              kxepal Alexander Shorin
              Reporter:
              kxepal Alexander Shorin
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development