diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2019-09-24 16:43:45 -0400 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2019-09-24 16:49:18 -0400 |
commit | a540b948524ce8ae860abd398c7af59c92bd2258 (patch) | |
tree | 21bf4384e8b0b168250d806fdddf258db3867164 | |
parent | a5b30e7828f16eb524eb58b53b9d0f48175fefcf (diff) | |
download | couchdb-a540b948524ce8ae860abd398c7af59c92bd2258.tar.gz |
Include search in the list of advertised features
The reason we don't do this in config:features() directly is because
this one is a dynamic check for the presence of a connected clouseau
node. Calling `enable_feature` every time we conduct that check seemed
too heavyweight, but I didn't see a good opportunity to just call it
once and be confident that it would reliably advertise the feature.
The downside here is that CouchDB will not advertise the "search"
feature if Clouseau is disconnected for maintenance or whatever,
although technically it's accurate since search requests submitted
during that interval would fail.
Closes #2205
-rw-r--r-- | src/chttpd/src/chttpd_misc.erl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl index 819d7820e..17122bf85 100644 --- a/src/chttpd/src/chttpd_misc.erl +++ b/src/chttpd/src/chttpd_misc.erl @@ -51,7 +51,7 @@ handle_welcome_req(#httpd{method='GET'}=Req, WelcomeMessage) -> {version, list_to_binary(couch_server:get_version())}, {git_sha, list_to_binary(couch_server:get_git_sha())}, {uuid, couch_server:get_uuid()}, - {features, config:features()} + {features, get_features()} ] ++ case config:get("vendor") of [] -> []; @@ -62,6 +62,14 @@ handle_welcome_req(#httpd{method='GET'}=Req, WelcomeMessage) -> handle_welcome_req(Req, _) -> send_method_not_allowed(Req, "GET,HEAD"). +get_features() -> + case clouseau_rpc:connected() of + true -> + [search | config:features()]; + false -> + config:features() + end. + handle_favicon_req(Req) -> handle_favicon_req(Req, get_docroot()). |