tdav::check_lock (public)
tdav::check_lock uri
Defined in packages/oacs-dav/tcl/tDAV-procs.tcl
Check whether the request may proceed under the resource's WebDAV lock. Remove an expired lock. If an active lock has no matching token in the If header, send HTTP 423.
- Parameters:
- uri (required)
- Resource URI.
- Returns:
- unlocked if the request may proceed, or filter_return after HTTP 423.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: regsub {^/} $uri {} uri # if lock exists, work. if not, just return. if {[file exists [tdav::get_lock_file $uri]]} { set lockinfo [tdav::read_lock $uri] # check if lock is expired if {[tdav::lock_timeout_left [lindex $lockinfo 4] [lindex $lockinfo 6]] == 0 } { tdav::remove_lock $uri return "unlocked" } set hdr [ns_set iget [ns_conn headers] If] # the If header exists, work, otherwise 423 if {[info exists hdr] && [string length $hdr]} { set token "" # add ? in the token re in case there is a conditional () # in the header regexp {(<https?://[^/]+([^>]+)>\s+)?\(<([^>]+)>\)} $hdr nil maybe hdr_uri token set ftk [lindex $lockinfo 3] if {![info exists token] || $token ne $ftk } { ns_log Debug "tdav::check_lock: token mismatch $ftk expected hdr: $hdr token: $token" ns_return 423 {text/plain} {} return filter_return } } else { ns_log Debug "tdav::check_lock: no \"If\" header found for request of $uri" ns_return 423 {text/plain} {} return filter_return } # also check for uri == hdr_uri } return unlockedXQL Not present: Generic, PostgreSQL, Oracle