You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2020/11/24 16:45:20 UTC
[couchdb] branch 3.x updated: Add missing default headers to
responses
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch 3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/3.x by this push:
new 23b9834 Add missing default headers to responses
23b9834 is described below
commit 23b98345f0db38214eaad33b159cf10dd9deaf72
Author: Bessenyei Balázs Donát <be...@apache.org>
AuthorDate: Mon Nov 23 11:45:39 2020 +0100
Add missing default headers to responses
---
src/chttpd/src/chttpd.erl | 5 +++--
src/couch_replicator/src/couch_replicator_httpd.erl | 2 +-
test/elixir/test/basics_test.exs | 10 ++++++++++
test/elixir/test/replication_test.exs | 14 ++++++++++++++
4 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl
index f55c6f1..16ed82e 100644
--- a/src/chttpd/src/chttpd.erl
+++ b/src/chttpd/src/chttpd.erl
@@ -1233,8 +1233,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 abd9f7f..6efd493 100644
--- a/src/couch_replicator/src/couch_replicator_httpd.erl
+++ b/src/couch_replicator/src/couch_replicator_httpd.erl
@@ -20,7 +20,7 @@
handle_scheduler_req/1
]).
--import(couch_httpd, [
+-import(chttpd, [
send_json/2,
send_json/3,
send_method_not_allowed/2
diff --git a/test/elixir/test/basics_test.exs b/test/elixir/test/basics_test.exs
index a03fa29..dbdc7d1 100644
--- a/test/elixir/test/basics_test.exs
+++ b/test/elixir/test/basics_test.exs
@@ -304,4 +304,14 @@ defmodule BasicsTest do
# TODO
assert true
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
diff --git a/test/elixir/test/replication_test.exs b/test/elixir/test/replication_test.exs
index 075f65b..12057d7 100644
--- a/test/elixir/test/replication_test.exs
+++ b/test/elixir/test/replication_test.exs
@@ -188,6 +188,20 @@ defmodule ReplicationTest do
assert resp.status_code == 200
end
+ test "default headers returned for _scheduler/jobs" do
+ resp = Couch.get("/_scheduler/jobs")
+ assert resp.headers["Content-Type"] == "application/json"
+ assert resp.headers["X-Couch-Request-ID"]
+ assert resp.headers["X-CouchDB-Body-Time"]
+ end
+
+ test "default headers returned for _scheduler/docs " do
+ resp = Couch.get("/_scheduler/docs")
+ assert resp.headers["Content-Type"] == "application/json"
+ assert resp.headers["X-Couch-Request-ID"]
+ assert resp.headers["X-CouchDB-Body-Time"]
+ end
+
Enum.each(@db_pairs_prefixes, fn {name, src_prefix, tgt_prefix} ->
@src_prefix src_prefix
@tgt_prefix tgt_prefix