Skip to content

Commit

Permalink
Remove support of HEAD request in signals index route (#58489)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rylnd and elasticmachine authored Feb 25, 2020
1 parent 0e23636 commit 2501919
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2501919

Please sign in to comment.