Remove support of HEAD request in signals index route (#58489) (#58539)

Until these are officially supported in new platform, it's best to not
rely on this behavior. We can achieve roughly the same functionality
with a GET request. Modifies the existing script accordingly, in case
anyone's still using it.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Ryland Herrick 2020-02-25 21:29:41 -06:00 committed by GitHub
parent 8d52178cbe
commit 8549ecf016
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 20 deletions

View file

@ -36,25 +36,14 @@ export const createReadIndexRoute = (
const indexExists = await getIndexExists(callCluster, index);
if (indexExists) {
// head request is used for if you want to get if the index exists
// or not and it will return a content-length: 0 along with either a 200 or 404
// depending on if the index exists or not.
if (request.method.toLowerCase() === 'head') {
return headers.response().code(200);
} else {
return headers.response({ name: index }).code(200);
}
return headers.response({ name: index }).code(200);
} else {
if (request.method.toLowerCase() === 'head') {
return headers.response().code(404);
} else {
return headers
.response({
message: 'index for this space does not exist',
status_code: 404,
})
.code(404);
}
return headers
.response({
message: 'index for this space does not exist',
status_code: 404,
})
.code(404);
}
} catch (err) {
const error = transformError(err);

View file

@ -10,7 +10,7 @@ set -e
./check_env_variables.sh
# Example: ./signal_index_exists.sh
curl -s -k --head \
curl -s -k -f \
-H 'Content-Type: application/json' \
-u ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD} \
${KIBANA_URL}${SPACE_URL}/api/detection_engine/index
${KIBANA_URL}${SPACE_URL}/api/detection_engine/index > /dev/null