diff options
author | Bessenyei Balázs Donát <bessbd@users.noreply.github.com> | 2020-11-23 11:45:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 10:45:39 +0000 |
commit | c362b1c11326050e09fd2ad5303e1221b38e8b0c (patch) | |
tree | 256d5368644156adca55c11a2d41488e8e838c9e | |
parent | 3168a4dbcef7181b67a989e1d723dc6a93e76280 (diff) | |
download | couchdb-c362b1c11326050e09fd2ad5303e1221b38e8b0c.tar.gz |
Add missing default headers to responses (#3279)
Add missing default headers to responses
-rw-r--r-- | src/chttpd/src/chttpd.erl | 5 | ||||
-rw-r--r-- | src/couch_replicator/src/couch_replicator_httpd.erl | 2 | ||||
-rw-r--r-- | src/couch_replicator/test/eunit/couch_replicator_db_tests.erl | 9 | ||||
-rw-r--r-- | test/elixir/test/basics_test.exs | 10 |
4 files changed, 23 insertions, 3 deletions
diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl index dc9a30fd7..636aad98b 100644 --- a/src/chttpd/src/chttpd.erl +++ b/src/chttpd/src/chttpd.erl @@ -1272,8 +1272,9 @@ basic_headers(Req, Headers0) -> ++ server_header() ++ couch_httpd_auth:cookie_auth_header(Req, Headers0), Headers1 = chttpd_cors:headers(Req, Headers), - Headers2 = chttpd_xframe_options:header(Req, Headers1), - chttpd_prefer_header:maybe_return_minimal(Req, Headers2). + Headers2 = chttpd_xframe_options:header(Req, Headers1), + Headers3 = [reqid(), timing() | Headers2], + chttpd_prefer_header:maybe_return_minimal(Req, Headers3). handle_response(Req0, Code0, Headers0, Args0, Type) -> {ok, {Req1, Code1, Headers1, Args1}} = diff --git a/src/couch_replicator/src/couch_replicator_httpd.erl b/src/couch_replicator/src/couch_replicator_httpd.erl index 196fcf203..0934ffe66 100644 --- a/src/couch_replicator/src/couch_replicator_httpd.erl +++ b/src/couch_replicator/src/couch_replicator_httpd.erl @@ -17,7 +17,7 @@ handle_scheduler_req/1 ]). --import(couch_httpd, [ +-import(chttpd, [ send_json/2, send_json/3, send_method_not_allowed/2 diff --git a/src/couch_replicator/test/eunit/couch_replicator_db_tests.erl b/src/couch_replicator/test/eunit/couch_replicator_db_tests.erl index 053441007..46133e2a8 100644 --- a/src/couch_replicator/test/eunit/couch_replicator_db_tests.erl +++ b/src/couch_replicator/test/eunit/couch_replicator_db_tests.erl @@ -36,6 +36,7 @@ couch_replicator_db_test_() -> ?TDEF_FE(replicator_db_deleted, 15), ?TDEF_FE(replicator_db_recreated, 15), ?TDEF_FE(invalid_replication_docs), + ?TDEF_FE(scheduler_default_headers_returned), ?TDEF_FE(duplicate_persistent_replication, 15), ?TDEF_FE(duplicate_transient_replication, 30) ] @@ -250,6 +251,14 @@ duplicate_transient_replication({Source, Target, RepDb}) -> wait_scheduler_docs_not_found(RepDb, DocId). +scheduler_default_headers_returned({_, _, _}) -> + SUrl = couch_replicator_test_helper:server_url(), + Url = lists:flatten(io_lib:format("~s/_scheduler/jobs", [SUrl])), + {ok, _, Headers, _} = test_request:get(Url, []), + ?assertEqual(true, lists:keymember("X-Couch-Request-ID", 1, Headers)), + ?assertEqual(true, lists:keymember("X-CouchDB-Body-Time", 1, Headers)). + + scheduler_jobs(Id) -> SUrl = couch_replicator_test_helper:server_url(), Url = lists:flatten(io_lib:format("~s/_scheduler/jobs/~s", [SUrl, Id])), diff --git a/test/elixir/test/basics_test.exs b/test/elixir/test/basics_test.exs index b9338c63f..f8f961222 100644 --- a/test/elixir/test/basics_test.exs +++ b/test/elixir/test/basics_test.exs @@ -518,4 +518,14 @@ defmodule BasicsTest do assert resp.status_code == 200 assert resp.body == 999 end + + @tag :with_db + test "Default headers are returned for doc with open_revs=all", context do + db_name = context[:db_name] + post_response = Couch.post("/#{db_name}", body: %{:foo => :bar}) + id = post_response.body["id"] + head_response = Couch.head("/#{db_name}/#{id}?open_revs=all") + assert head_response.headers["X-Couch-Request-ID"] + assert head_response.headers["X-CouchDB-Body-Time"] + end end |