Roxen.git
/
server
/
base_server
/
module.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/base_server/module.pike:1:
// This file is part of Roxen WebServer. // Copyright © 1996 - 2001, Roxen IS.
-
// $Id: module.pike,v 1.
175
2004/05/
04
17
:
53
:
22
mast
Exp $
+
// $Id: module.pike,v 1.
176
2004/05/
05
13
:
54
:
32
grubba
Exp $
#include <module_constants.h> #include <module.h> #include <request_trace.h> constant __pragma_save_parent__ = 1; inherit "basic_defvar"; mapping(string:array(int)) error_log=([]);
Roxen.git/server/base_server/module.pike:917:
else { removed_lock = m_delete (file_locks[path], auth_user); if (!sizeof (file_locks[path])) m_delete (file_locks, path); } ASSERT_IF_DEBUG (!removed_lock || lock /*%O*/ == removed_lock /*%O*/, lock, removed_lock); TRACE_LEAVE("Ok."); return 0; }
+
//! Check if we may perform a write access to @[path].
+
//!
+
//! Checks if the current locks match the if-header.
+
//!
+
//! Usually called from @[find_file()].
+
//!
+
//! @note
+
//! Does not support checking against etags yet.
+
//!
+
//! @returns
+
//! Returns @expr{0@} (zero) on success and
+
//! a result mapping on failure.
+
mapping(string:mixed) access_path(string path, RequestID id)
+
{
+
if (!sizeof(path) || (path[-1] != '/')) path += "/";
-
+
int(0..3)|DAVLock lock = check_locks(path, 0, id);
+
+
if (lock && intp(lock)) return Roxen.http_status(423);
+
+
mapping(string:array(array(array(string)))) if_data = id->get_if_data();
+
array(array(array(string))) condition;
+
if (!if_data || !sizeof(condition = if_data[path] || if_data[0])) {
+
if (lock) return Roxen.http_status(423);
+
return 0; // No condition and no lock -- Ok.
+
}
+
next_condition:
+
foreach(condition, array(array(string)) sub_cond) {
+
int negate;
+
foreach(sub_cond, array(string) token) {
+
switch(token[0]) {
+
case "not":
+
negate = !negate;
+
break;
+
case "etag":
+
// Not supported yet.
+
continue next_contition; // Fail.
+
case "lock":
+
if ((lock && lock->locktoken == token[1]) != negate) {
+
// Lock mismatch.
+
continue next_contition; // Fail.
+
}
+
negate = 0;
+
break;
+
}
+
}
+
return 0; // Found matching sub-condition.
+
}
+
if (lock) return Roxen.http_status(423);
+
return Roxen.http_status(412);
+
}
+
mapping(string:mixed)|int(-1..0)|Stdio.File find_file(string path, RequestID id); //! Delete the file specified by @[path]. //! //! @note //! Should return a 204 status on success. //! //! @note //! The default implementation falls back to @[find_file()].