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

ensure_full_commit requires empty but typed content or it will unexpectedly drops the connection

    Details

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

      Description

      When given an non-empty (but valid) JSON content, some methods such as _ensure_full_commit will abruptly drop a persistent connection instead of waiting for a new HTTP request even though no error is signaled in CouchDB logs:

      Request
      POST /testdb1/_ensure_full_commit HTTP/1.1
      Host: localhost:5984
      Accept: application/json
      Content-Type: application/json
      Content-Length: 2
      
      {}
      
      Response
      HTTP/1.1 201 Created
      Server: CouchDB/1.6.1 (Erlang OTP/17)
      Date: Mon, 16 Feb 2015 11:49:11 GMT
      Content-Type: application/json
      Content-Length: 53
      Cache-Control: must-revalidate
      
      {"ok":true,"instance_start_time":"1424085277160411"}
      

      [connection is closed without warning by CouchDB at this point]

      To remedy that, one could try to give an empty content, but some frameworks (such as spray.io) will systematically omit the Content-Type header in this case since it makes little sense to type empty content. However, CouchDB will reject the request even though it does not want any content:

      Request
      POST /testdb1/_ensure_full_commit HTTP/1.1
      Host: localhost:5984
      Accept: application/json
      Content-Length: 0
      
      Response
      HTTP/1.1 415 Unsupported Media Type
      Server: CouchDB/1.6.1 (Erlang OTP/17)
      Date: Mon, 16 Feb 2015 11:55:52 GMT
      Content-Type: application/json
      Content-Length: 78
      Cache-Control: must-revalidate
      
      {"error":"bad_content_type","reason":"Content-Type must be application/json"}
      

      This makes it impossible to use those methods with such frameworks. CouchDB should not drop the connection and ignore the data if Content-Length is not 0, nor require that data be typed with application/json if it is going to ignore it anyway or if it requires it to be empty.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sam@rfc1149.net Samuel Tardieu
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: