From 50becf8ae342c02d32015675bc4f3f3bc0fc6ea7 Mon Sep 17 00:00:00 2001 From: Brandon Robins Date: Sat, 25 Nov 2017 16:40:37 -0600 Subject: [PATCH] Use consistent headers method and/or variable --- lib/calligraphy/lock.rb | 2 +- lib/calligraphy/put.rb | 2 +- .../rails/web_dav_requests_controller.rb | 16 ++++++---------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/calligraphy/lock.rb b/lib/calligraphy/lock.rb index e8cd323..16917ac 100644 --- a/lib/calligraphy/lock.rb +++ b/lib/calligraphy/lock.rb @@ -14,7 +14,7 @@ module Calligraphy xml = xml_for body: body, node: 'lockinfo' return :bad_request if xml == :bad_request - lock_properties = @resource.lock xml, headers['Depth'] + lock_properties = @resource.lock xml, @headers['Depth'] end builder = xml_builder diff --git a/lib/calligraphy/put.rb b/lib/calligraphy/put.rb index 4e03c1a..05564e5 100644 --- a/lib/calligraphy/put.rb +++ b/lib/calligraphy/put.rb @@ -1,7 +1,7 @@ module Calligraphy class Put < WebDavRequest def request - return :locked if @resource.locked_to_user? headers + return :locked if @resource.locked_to_user? @headers return :method_not_allowed if @resource.collection? @resource.write diff --git a/lib/calligraphy/rails/web_dav_requests_controller.rb b/lib/calligraphy/rails/web_dav_requests_controller.rb index 9264d97..f0cb7f8 100644 --- a/lib/calligraphy/rails/web_dav_requests_controller.rb +++ b/lib/calligraphy/rails/web_dav_requests_controller.rb @@ -39,12 +39,8 @@ module Calligraphy::Rails @resource = @resource_class.new resource: resource_id, req: request, root_dir: @resource_root_path end - def headers - request.headers - end - def check_preconditions - return true unless headers['If'].present? + return true unless request.headers['If'].present? evaluate_if_header end @@ -64,10 +60,10 @@ module Calligraphy::Rails end def get_if_conditions - lists = if headers['If'][0] == '<' - headers['If'].split Calligraphy::TAGGED_LIST_REGEX + lists = if request.headers['If'][0] == '<' + request.headers['If'].split Calligraphy::TAGGED_LIST_REGEX else - headers['If'].split Calligraphy::UNTAGGAGED_LIST_REGEX + request.headers['If'].split Calligraphy::UNTAGGAGED_LIST_REGEX end lists @@ -110,7 +106,7 @@ module Calligraphy::Rails if target.locked? conditions_met = false unless target.lock_tokens&.include? conditions[:lock_token] else - conditions_met = false if target.locked_to_user? headers + conditions_met = false if target.locked_to_user? request.headers end end @@ -129,7 +125,7 @@ module Calligraphy::Rails end def web_dav_request - { headers: headers, request: request, resource: @resource, response: response } + { headers: request.headers, request: request, resource: @resource, response: response } end def options