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

Duplicate application/json in response Content-Type for show/update functions

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0, 1.7.0
    • Component/s: HTTP Interface
    • Labels:
      None

      Description

      Show function:

      function(doc,req){
        return {"json": true}
      }
      

      Curl command:

      curl -v  http://localhost:5984/db/_design/test/_show/json -H "Accept: application/json"
       
      * Adding handle: conn: 0x24d8480
      * Adding handle: send: 0
      * Adding handle: recv: 0
      * Curl_addHandleToPipeline: length: 1
      * - Conn 0 (0x24d8480) send_pipe: 1, recv_pipe: 0
      * About to connect() to localhost port 5984 (#0)
      *   Trying 127.0.0.1...
      * Connected to localhost (127.0.0.1) port 5984 (#0)
      > GET /db/_design/test/_show/json HTTP/1.1
      > User-Agent: curl/7.31.0
      > Host: localhost:5984
      > Accept: application/json
      > 
      < HTTP/1.1 200 OK
      < Vary: Accept
      * Server CouchDB/1.4.0+build.c843cef (Erlang OTP/R16B) is not blacklisted
      < Server: CouchDB/1.4.0+build.c843cef (Erlang OTP/R16B)
      < Etag: "AW5C2CXR0TS88IZ5N8ZIY995B"
      < Date: Wed, 21 Aug 2013 16:06:00 GMT
      < Content-Type: application/json, application/json
      < Content-Length: 7
      < Cache-Control: must-revalidate
      < 
      "true"
      * Connection #0 to host localhost left intact
      
      

      Note line in response with:

      Content-Type: application/json, application/json

      While it's ok for HTTP, I believe there should be only one "application/json" MIME type.

        Activity

        Hide
        jbooze Josh added a comment -

        Is this bug ever going to be fixed?

        Show
        jbooze Josh added a comment - Is this bug ever going to be fixed?
        Hide
        kxepal Alexander Shorin added a comment -

        Josh patches welcome! should be trivial.

        Show
        kxepal Alexander Shorin added a comment - Josh patches welcome! should be trivial.
        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user arturmazurek opened a pull request:

        https://github.com/apache/couchdb-couch/pull/53

        Fix duplicated Content-Type for show/update functions

        When a show/update function returned data it added a
        "Content-Type: application/json" header by itself. Then
        couch_httpd added some default headers (including a yet
        another "application/json" one).
        This diff deduplicates those headers using a set.

        COUCHDB-1876

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

        $ git pull https://github.com/arturmazurek/couchdb-couch 1876-fix-duplicate-content-type

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

        https://github.com/apache/couchdb-couch/pull/53.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 #53


        commit 7a75cce61f3616333883703b6e098961079d5295
        Author: Artur Mazurek <artur.s.mazurek@gmail.com>
        Date: 2015-05-25T14:19:53Z

        Fix duplicated Content-Type for show/update functions

        When a show/update function returned data it added a
        "Content-Type: application/json" header by itself. Then
        couch_httpd added some default headers (including a yet
        another "application/json" one).
        This diff deduplicates those headers using a set.

        COUCHDB-1876


        Show
        githubbot ASF GitHub Bot added a comment - GitHub user arturmazurek opened a pull request: https://github.com/apache/couchdb-couch/pull/53 Fix duplicated Content-Type for show/update functions When a show/update function returned data it added a "Content-Type: application/json" header by itself. Then couch_httpd added some default headers (including a yet another "application/json" one). This diff deduplicates those headers using a set. COUCHDB-1876 You can merge this pull request into a Git repository by running: $ git pull https://github.com/arturmazurek/couchdb-couch 1876-fix-duplicate-content-type Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-couch/pull/53.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 #53 commit 7a75cce61f3616333883703b6e098961079d5295 Author: Artur Mazurek <artur.s.mazurek@gmail.com> Date: 2015-05-25T14:19:53Z Fix duplicated Content-Type for show/update functions When a show/update function returned data it added a "Content-Type: application/json" header by itself. Then couch_httpd added some default headers (including a yet another "application/json" one). This diff deduplicates those headers using a set. COUCHDB-1876
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user arturmazurek closed the pull request at:

        https://github.com/apache/couchdb-couch/pull/53

        Show
        githubbot ASF GitHub Bot added a comment - Github user arturmazurek closed the pull request at: https://github.com/apache/couchdb-couch/pull/53
        Hide
        fszczemton Artur Mazurek added a comment - - edited

        Also FYI, without specifying the Accept header, the content type response also is wrong:
        Content-Type: text/plain; charset=utf-8, application/json

        Show
        fszczemton Artur Mazurek added a comment - - edited Also FYI, without specifying the Accept header, the content type response also is wrong: Content-Type: text/plain; charset=utf-8, application/json
        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user arturmazurek opened a pull request:

        https://github.com/apache/couchdb-couch/pull/55

        Fix duplicated Content-Type for show/update functions

        When a show/update function returned data it added a
        "Content-Type: application/json" header by itself. Then
        couch_httpd added some default headers (including a yet
        another "application/json" one).
        This diff will add default chttpd headers only when
        same headers are not yet present in the response.

        COUCHDB-1876

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

        $ git pull https://github.com/arturmazurek/couchdb-couch 1876-fix-duplicate-content-type

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

        https://github.com/apache/couchdb-couch/pull/55.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 #55


        commit 0e85057a256635fff4a21cbe9368188a32c46650
        Author: Artur Mazurek <artur.s.mazurek@gmail.com>
        Date: 2015-05-25T14:19:53Z

        Fix duplicated Content-Type for show/update functions

        When a show/update function returned data it added a
        "Content-Type: application/json" header by itself. Then
        couch_httpd added some default headers (including a yet
        another "application/json" one).
        This diff will add default chttpd headers only when
        same headers are not yet present in the response.

        COUCHDB-1876


        Show
        githubbot ASF GitHub Bot added a comment - GitHub user arturmazurek opened a pull request: https://github.com/apache/couchdb-couch/pull/55 Fix duplicated Content-Type for show/update functions When a show/update function returned data it added a "Content-Type: application/json" header by itself. Then couch_httpd added some default headers (including a yet another "application/json" one). This diff will add default chttpd headers only when same headers are not yet present in the response. COUCHDB-1876 You can merge this pull request into a Git repository by running: $ git pull https://github.com/arturmazurek/couchdb-couch 1876-fix-duplicate-content-type Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-couch/pull/55.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 #55 commit 0e85057a256635fff4a21cbe9368188a32c46650 Author: Artur Mazurek <artur.s.mazurek@gmail.com> Date: 2015-05-25T14:19:53Z Fix duplicated Content-Type for show/update functions When a show/update function returned data it added a "Content-Type: application/json" header by itself. Then couch_httpd added some default headers (including a yet another "application/json" one). This diff will add default chttpd headers only when same headers are not yet present in the response. COUCHDB-1876
        Hide
        richardwooding Richard Wooding added a comment -

        I'm experiencing this issue right now. My REST client library is not handling the duplicated "application/json" cleanly

        Show
        richardwooding Richard Wooding added a comment - I'm experiencing this issue right now. My REST client library is not handling the duplicated "application/json" cleanly
        Hide
        kxepal Alexander Shorin added a comment -

        Richard Wooding, just curious what REST client do you use?

        Show
        kxepal Alexander Shorin added a comment - Richard Wooding , just curious what REST client do you use?
        Hide
        richardwooding Richard Wooding added a comment - - edited

        I use a client https://grails.org/plugin/rest-client-builder which is based on Spring's RestTemplate.

        https://grails.org/plugin/rest-client-builder
        https://github.com/grails-plugins/grails-rest-client-builder/
        http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html

        Yes it's Groovy/Grails, I've very succesfully integrated CouchDB into my project. Only problem is this duplicate application/json in the content-type header on a update handler.

        Show
        richardwooding Richard Wooding added a comment - - edited I use a client https://grails.org/plugin/rest-client-builder which is based on Spring's RestTemplate. https://grails.org/plugin/rest-client-builder https://github.com/grails-plugins/grails-rest-client-builder/ http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html Yes it's Groovy/Grails, I've very succesfully integrated CouchDB into my project. Only problem is this duplicate application/json in the content-type header on a update handler.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit c63796e4e5b7f649d461f6b72494dc9f9246a59e in couchdb-couch's branch refs/heads/master from Artur Mazurek
        [ https://git-wip-us.apache.org/repos/asf?p=couchdb-couch.git;h=c63796e ]

        Fix duplicated Content-Type for show/update functions

        When a show/update function returned data it added a
        "Content-Type: application/json" header by itself. Then
        couch_httpd added some default headers (including a yet
        another "application/json" one).
        This diff will add default chttpd headers only when
        same headers are not yet present in the response.

        This closes #55

        COUCHDB-1876

        Signed-off-by: Alexander Shorin <kxepal@apache.org>

        Show
        jira-bot ASF subversion and git services added a comment - Commit c63796e4e5b7f649d461f6b72494dc9f9246a59e in couchdb-couch's branch refs/heads/master from Artur Mazurek [ https://git-wip-us.apache.org/repos/asf?p=couchdb-couch.git;h=c63796e ] Fix duplicated Content-Type for show/update functions When a show/update function returned data it added a "Content-Type: application/json" header by itself. Then couch_httpd added some default headers (including a yet another "application/json" one). This diff will add default chttpd headers only when same headers are not yet present in the response. This closes #55 COUCHDB-1876 Signed-off-by: Alexander Shorin <kxepal@apache.org>
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/couchdb-couch/pull/55

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

        Commit b6638e35e326e7fafdfddce10ec3e6a990c4639f in couchdb's branch refs/heads/1.x.x from Artur Mazurek
        [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=b6638e3 ]

        Fix duplicated Content-Type for show/update functions

        COUCHDB-1876

        Signed-off-by: Alexander Shorin <kxepal@apache.org>

        Show
        jira-bot ASF subversion and git services added a comment - Commit b6638e35e326e7fafdfddce10ec3e6a990c4639f in couchdb's branch refs/heads/1.x.x from Artur Mazurek [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=b6638e3 ] Fix duplicated Content-Type for show/update functions COUCHDB-1876 Signed-off-by: Alexander Shorin <kxepal@apache.org>
        Hide
        kxepal Alexander Shorin added a comment -

        Richard Wooding, patch landed on 1.x.x branch and for 2.0. Your issue should be fixed.

        Show
        kxepal Alexander Shorin added a comment - Richard Wooding , patch landed on 1.x.x branch and for 2.0. Your issue should be fixed.
        Hide
        richardwooding Richard Wooding added a comment -
        Show
        richardwooding Richard Wooding added a comment - Thanks Alexander Shorin
        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user rnewson opened a pull request:

        https://github.com/apache/couchdb-couch/pull/100

        Use lists:ukeymerge to simplify header deduplication

        Modifies COUCHDB-1876 patch

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

        $ git pull https://github.com/cloudant/couchdb-couch simplify-1876

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

        https://github.com/apache/couchdb-couch/pull/100.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 #100


        commit cb58087c9ad50f1e4e04a484b8fa3e833ece2d49
        Author: Robert Newson <rnewson@apache.org>
        Date: 2015-09-17T11:48:07Z

        Use lists:ukeymerge to simplify header deduplication

        Modifies COUCHDB-1876 patch


        Show
        githubbot ASF GitHub Bot added a comment - GitHub user rnewson opened a pull request: https://github.com/apache/couchdb-couch/pull/100 Use lists:ukeymerge to simplify header deduplication Modifies COUCHDB-1876 patch You can merge this pull request into a Git repository by running: $ git pull https://github.com/cloudant/couchdb-couch simplify-1876 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-couch/pull/100.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 #100 commit cb58087c9ad50f1e4e04a484b8fa3e833ece2d49 Author: Robert Newson <rnewson@apache.org> Date: 2015-09-17T11:48:07Z Use lists:ukeymerge to simplify header deduplication Modifies COUCHDB-1876 patch
        Hide
        jira-bot ASF subversion and git services added a comment -

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

        Use lists:ukeymerge to simplify header deduplication

        Modifies COUCHDB-1876 patch

        Show
        jira-bot ASF subversion and git services added a comment - Commit cb58087c9ad50f1e4e04a484b8fa3e833ece2d49 in couchdb-couch's branch refs/heads/master from Robert Newson [ https://git-wip-us.apache.org/repos/asf?p=couchdb-couch.git;h=cb58087 ] Use lists:ukeymerge to simplify header deduplication Modifies COUCHDB-1876 patch
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/couchdb-couch/pull/100

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

          People

          • Assignee:
            Unassigned
            Reporter:
            kxepal Alexander Shorin
          • Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development