This is an automated email from the ASF dual-hosted git repository. eiri pushed a commit to branch fix-delete-chunked-response in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit fb55897a93e7aaa8ea5b8284549bd07d489fc5b8 Author: Eric Avdey <[email protected]> AuthorDate: Wed Aug 25 09:10:35 2021 -0300 Discard a payload on a delete attachment request While including a payload within a DELETE request is not forbidden by RFC7231 its presence on a delete attachment request leaves a mochiweb acceptor in a semi-opened state since mochiweb's using lazy load for the request bodies. This makes a next immediate request to the same acceptor to hung until previous request's receive timeout. This PR adds a step to explicitly "drain" and discard an entity body on a delete attachment request to prevent that. --- src/chttpd/src/chttpd_db.erl | 3 +++ test/elixir/test/attachments_test.exs | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl index ffdab2a..e803454 100644 --- a/src/chttpd/src/chttpd_db.erl +++ b/src/chttpd/src/chttpd_db.erl @@ -857,6 +857,9 @@ db_req(#httpd{path_parts=[_DbName, <<"_local">> | _Rest]}, _Db) -> db_req(#httpd{path_parts=[_, DocId]}=Req, Db) -> db_doc_req(Req, Db, DocId); +db_req(#httpd{method='DELETE', path_parts=[_, DocId | FileNameParts]}=Req, Db) -> + chttpd:body(Req), + db_attachment_req(Req, Db, DocId, FileNameParts); db_req(#httpd{path_parts=[_, DocId | FileNameParts]}=Req, Db) -> db_attachment_req(Req, Db, DocId, FileNameParts). diff --git a/test/elixir/test/attachments_test.exs b/test/elixir/test/attachments_test.exs index c89486a..2bf38de 100644 --- a/test/elixir/test/attachments_test.exs +++ b/test/elixir/test/attachments_test.exs @@ -124,6 +124,21 @@ defmodule AttachmentsTest do end @tag :with_db + test "delete attachment request with a payload should not block following requests", context do + db_name = context[:db_name] + + resp = Couch.put("/#{db_name}/bin_doc", body: @bin_att_doc, query: %{w: 3}) + assert resp.status_code in [201, 202] + rev = resp.body["rev"] + + resp = Couch.delete("/#{db_name}/bin_doc/foo.txt", body: 'some payload', query: %{w: 3, rev: rev}, ibrowse: [{:max_sessions, 1}, {:max_pipeline_size, 1}]) + assert resp.status_code == 200 + + resp = Couch.get("/", timeout: 1000, ibrowse: [{:max_sessions, 1}, {:max_pipeline_size, 1}]) + assert resp.status_code == 200 + end + + @tag :with_db test "saves binary", context do db_name = context[:db_name]
