diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2017-03-01 14:35:48 +0100 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2017-08-28 16:40:25 +0200 |
commit | 998afa5f74558be215a924d95aa131a69831ca43 (patch) | |
tree | 500c242e2bacd966b3faf1a019f28edff2ee24d7 /lib/api/helpers.rb | |
parent | 7ccef75a26bc4997e04c109007e6c6ee004574cb (diff) | |
download | gitlab-ce-998afa5f74558be215a924d95aa131a69831ca43.tar.gz |
API: Respect the 'If-Unmodified-Since' for delete endpoints
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index b56fd2388b3..1c74a14d91c 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -11,6 +11,14 @@ module API declared(params, options).to_h.symbolize_keys end + def check_unmodified_since(last_modified) + if_unmodified_since = Time.parse(headers['If-Unmodified-Since']) if headers.key?('If-Unmodified-Since') rescue nil + + if if_unmodified_since && if_unmodified_since < last_modified + render_api_error!('412 Precondition Failed', 412) + end + end + def current_user return @current_user if defined?(@current_user) |