Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9792710D02 for ; Mon, 16 Feb 2015 13:35:12 +0000 (UTC) Received: (qmail 86058 invoked by uid 500); 16 Feb 2015 13:35:12 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 85995 invoked by uid 500); 16 Feb 2015 13:35:12 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 85983 invoked by uid 99); 16 Feb 2015 13:35:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Feb 2015 13:35:12 +0000 Date: Mon, 16 Feb 2015 13:35:12 +0000 (UTC) From: "Samuel Tardieu (JIRA)" To: dev@couchdb.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COUCHDB-2583) ensure_full_commit requires empty but typed content or it will unexpectedly drops the connection MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-2583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14322761#comment-14322761 ] Samuel Tardieu commented on COUCHDB-2583: ----------------------------------------- I have trivially modified CouchDB (patch attached) to make {{_ensure_full_commit}} and {{_compact}} consume the body of the HTTP request according to the {{Content-Length}} header. It fixes the issue on my side, feel free to apply it with {{git am}}, or to ask a resubmission using another channel if needed. > ensure_full_commit requires empty but typed content or it will unexpectedly drops the connection > ------------------------------------------------------------------------------------------------ > > Key: COUCHDB-2583 > URL: https://issues.apache.org/jira/browse/COUCHDB-2583 > Project: CouchDB > Issue Type: Bug > Security Level: public(Regular issues) > Components: HTTP Interface > Affects Versions: 1.6.1 > Reporter: Samuel Tardieu > Attachments: 0001-Consume-JSON-body-even-if-ignored.patch > > > 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: > {code:title=Request} > POST /testdb1/_ensure_full_commit HTTP/1.1 > Host: localhost:5984 > Accept: application/json > Content-Type: application/json > Content-Length: 2 > {} > {code} > {code:title=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"} > {code} > [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: > {code:title=Request} > POST /testdb1/_ensure_full_commit HTTP/1.1 > Host: localhost:5984 > Accept: application/json > Content-Length: 0 > {code} > {code:title=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"} > {code} > 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. -- This message was sent by Atlassian JIRA (v6.3.4#6332)