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 - 2001, Roxen IS. - // $Id: module.pike,v 1.196 2004/05/10 21:37:30 mast Exp $ + // $Id: module.pike,v 1.197 2004/05/12 12:06:44 mast 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:1136:    lock->locktoken);    }       TRACE_LEAVE("Failed.");    return res || Roxen.http_status(Protocols.HTTP.HTTP_PRECOND_FAILED);   }      mapping(string:mixed)|int(-1..0)|Stdio.File find_file(string path,    RequestID id);    - //! Delete the file specified by @[path]. It's unspecified if it works - //! recursively or not. + //! Delete the file specified by @[path].   //! - //! @note - //! Should return a 204 status on success. + //! It's unspecified if it works recursively or not, but if it does + //! then it has to check DAV locks through @[write_access] + //! recursively.   //! -  + //! @returns + //! Returns a 204 status on success, 0 if the file doesn't exist, or + //! an appropriate status mapping for any other error. + //!   //! @note   //! The default implementation falls back to @[find_file()].   mapping(string:mixed) delete_file(string path, RequestID id)   {    // Fall back to find_file().    RequestID tmp_id = id->clone_me();    tmp_id->not_query = query_location() + path;    tmp_id->method = "DELETE";    // FIXME: Logging?    return find_file(path, tmp_id) ||
Roxen.git/server/base_server/module.pike:1164:      //! Delete @[path] recursively.   //! @returns   //! Returns @expr{0@} (zero) on file not found.   //! Returns @[Roxen.http_status(204)] on success.   //! Returns other result mappings on failure.   mapping(string:mixed) recurse_delete_files(string path,    RequestID id,    void|MultiStatus.Prefixed stat)   { +  SIMPLE_TRACE_ENTER (this, "Deleting %O recursively", path);    if (!stat)    id->get_multi_status()->prefix (id->url_base() + query_location()[1..]);    -  mapping(string:mixed) recurse (string path) -  { +     Stat st = stat_file(path, id); -  if (!st) return 0; +  if (!st) { +  SIMPLE_TRACE_LEAVE ("No such file or directory"); +  return 0; +  } +  +  mapping(string:mixed) recurse (string path, Stat st) +  { +  // Note: Already got an extra TRACE_ENTER level on entry here. +     if (st->isdir) {    // RFC 2518 8.6.2    // The DELETE operation on a collection MUST act as if a    // "Depth: infinity" header was used on it.    int fail;    if (!has_suffix(path, "/")) path += "/";    foreach(find_dir(path, id) || ({}), string fname) { -  mapping(string:mixed) sub_res = recurse(path+fname); +  fname = path + fname; +  if (Stat sub_stat = stat_file (fname, id)) { +  SIMPLE_TRACE_ENTER (this, "Deleting %O recursively", fname); +  mapping(string:mixed) sub_res = recurse(fname, sub_stat);    // RFC 2518 8.6.2    // 424 (Failed Dependancy) errors SHOULD NOT be in the    // 207 (Multi-Status).    //    // Additionally 204 (No Content) errors SHOULD NOT be returned    // in the 207 (Multi-Status). The reason for this prohibition    // is that 204 (No Content) is the default success code.    if (sub_res && sub_res->error != 204 && sub_res->error != 424) { -  stat->add_status(path+fname, sub_res->error, sub_res->rettext); +  stat->add_status(fname, sub_res->error, sub_res->rettext);    if (sub_res->error >= 300) fail = 1;    }    } -  if (fail) return Roxen.http_status(424); +     } -  +  if (fail) { +  SIMPLE_TRACE_LEAVE ("Partial failure"); +  return Roxen.http_status(424); +  } +  } +  +  SIMPLE_TRACE_LEAVE (""); +  return 0;    };    -  return recurse (path) || delete_file(path, id) || Roxen.http_status(204); +  return recurse(path, st) || delete_file(path, id) || Roxen.http_status(204);   }      mapping(string:mixed) make_collection(string path, RequestID id)   {    // Fall back to find_file().    RequestID tmp_id = id->clone_me();    tmp_id->not_query = query_location() + path;    tmp_id->method = "MKCOL";    // FIXME: Logging?    return find_file(path, tmp_id);