Skip to content

Commit

Permalink
Remove support of HEAD request in signals index route (elastic#58489) (
Browse files Browse the repository at this point in the history
…elastic#58540)

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]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
rylnd and elasticmachine authored Feb 26, 2020
1 parent 4e61c13 commit a3ca2d2
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 @@ -29,25 +29,14 @@ export const createReadIndexRoute = (server: ServerFacade): Hapi.ServerRoute =>
const callWithRequest = callWithRequestFactory(request, server);
const indexExists = await getIndexExists(callWithRequest, 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 a3ca2d2

Please sign in to comment.