From 3b3bcb1bafe60bd5d8abc1fb05953cbf673872a0 Mon Sep 17 00:00:00 2001 From: Victor Boctor Date: Fri, 24 Nov 2017 16:24:35 -0800 Subject: [PATCH] Use `If-Match` instead of `If-None-Match` for update/delete --- api/rest/restcore/issues_rest.php | 8 ++++---- core/constant_inc.php | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/rest/restcore/issues_rest.php b/api/rest/restcore/issues_rest.php index d71b00ad98..dee15eccd6 100644 --- a/api/rest/restcore/issues_rest.php +++ b/api/rest/restcore/issues_rest.php @@ -159,8 +159,8 @@ function rest_issue_delete( \Slim\Http\Request $p_request, \Slim\Http\Response $ $t_etag = mc_issue_hash( $t_issue_id, /* issue */ null ); } - if( $p_request->hasHeader( HEADER_IF_NONE_MATCH ) ) { - $t_match_etag = $p_request->getHeaderLine( HEADER_IF_NONE_MATCH ); + if( $p_request->hasHeader( HEADER_IF_MATCH ) ) { + $t_match_etag = $p_request->getHeaderLine( HEADER_IF_MATCH ); if( $t_etag != $t_match_etag ) { return $p_response->withStatus( HTTP_STATUS_PRECONDITION_FAILED, 'Precondition Failed' ) ->withHeader( HEADER_ETAG, $t_etag ); @@ -282,8 +282,8 @@ function rest_issue_update( \Slim\Http\Request $p_request, \Slim\Http\Response $ $t_issue = null; } - if( $p_request->hasHeader( HEADER_IF_NONE_MATCH ) ) { - $t_match_etag = $p_request->getHeaderLine( HEADER_IF_NONE_MATCH ); + if( $p_request->hasHeader( HEADER_IF_MATCH ) ) { + $t_match_etag = $p_request->getHeaderLine( HEADER_IF_MATCH ); if( $t_etag != $t_match_etag ) { return $p_response->withStatus( HTTP_STATUS_PRECONDITION_FAILED, 'Precondition Failed' ) ->withHeader( HEADER_ETAG, $t_etag ); diff --git a/core/constant_inc.php b/core/constant_inc.php index e80986df50..03ecd3f251 100644 --- a/core/constant_inc.php +++ b/core/constant_inc.php @@ -680,6 +680,7 @@ define( 'HEADER_LOGIN_METHOD', 'X-Mantis-LoginMethod' ); define( 'HEADER_USERNAME', 'X-Mantis-Username' ); define( 'HEADER_VERSION', 'X-Mantis-Version' ); +define( 'HEADER_IF_MATCH', 'If-Match' ); define( 'HEADER_IF_NONE_MATCH', 'If-None-Match' ); define( 'HEADER_ETAG', 'ETag' );