Roxen.git / server / base_server / module.pike

version» Context lines:

Roxen.git/server/base_server/module.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2009, Roxen IS. - // $Id: module.pike,v 1.245 2012/01/23 12:50:52 grubba Exp $ + // $Id$      #include <module_constants.h>   #include <module.h>   #include <request_trace.h>      constant __pragma_save_parent__ = 1;      // Tell Pike.count_memory this is global.   constant pike_cycle_depth = 0;   
Roxen.git/server/base_server/module.pike:1251:   {    SIMPLE_TRACE_ENTER(this, "Checking \"If\" header for %O",    relative_path);       int/*LockFlag*/|DAVLock lock = check_locks(relative_path, recursive, id);       int(0..1) got_sublocks;    if (lock && intp(lock)) {    if (lock & 1) {    TRACE_LEAVE("Locked by other user."); -  return Roxen.http_status(Protocols.HTTP.DAV_LOCKED); +  return Roxen.http_dav_error(Protocols.HTTP.DAV_LOCKED, +  "lock-token-submitted");    }    else if (recursive)    // This is set for LOCK_OWN_BELOW too since it might be    // necessary to come back here and check the If header for    // those locks.    got_sublocks = 1;    }       string path = relative_path;    if (!has_suffix (path, "/")) path += "/"; // get_if_data always adds a "/".    path = query_location() + path; // No need for fancy combine_path stuff here.       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) {    TRACE_LEAVE("Locked, no if header."); -  return Roxen.http_status(Protocols.HTTP.DAV_LOCKED); +  return Roxen.http_dav_error(Protocols.HTTP.DAV_LOCKED, +  "lock-token-submitted");    }    SIMPLE_TRACE_LEAVE("No lock and no if header - ok%s.",    got_sublocks ? " (this level only)" : "");    return got_sublocks; // No condition and no lock -- Ok.    }       string|int(-1..0) etag;       int(0..1) locked_fail = !!lock;    next_condition:
Roxen.git/server/base_server/module.pike:1342:    TRACE_LEAVE("Found match.");    SIMPLE_TRACE_LEAVE("Ok%s.",    got_sublocks ? " (this level only)" : "");    return got_sublocks; // Found matching sub-condition.    }    SIMPLE_TRACE_LEAVE("Conditional ok, but still locked (locktoken: %O).",    lock->locktoken);    locked_fail = 1;    }    -  TRACE_LEAVE("Failed."); -  return Roxen.http_status(locked_fail ? -  Protocols.HTTP.DAV_LOCKED : -  Protocols.HTTP.HTTP_PRECOND_FAILED); +  if (locked_fail) { +  TRACE_LEAVE("Failed (locked)."); +  return Roxen.http_dav_error(Protocols.HTTP.DAV_LOCKED, +  "lock-token-submitted");    }    -  +  TRACE_LEAVE("Precondition failed."); +  return Roxen.http_status(Protocols.HTTP.HTTP_PRECOND_FAILED); + } +    //! Used by some default implementations to check if we may perform a   //! write access to @[path]. It should at least call   //! @[check_if_header] to check DAV locks. It takes the same arguments   //! and has the same return value as that function.   //!   //! WARNING: This function has some design issues and will very likely   //! get a different interface. Compatibility is NOT guaranteed.   //!   //! A filesystem module should typically put all needed write access   //! checks here and then use this from @[find_file()],