Roxen.git / server / etc / modules / PropertySet.pike

version» Context lines:

Roxen.git/server/etc/modules/PropertySet.pike:1:   //! Contains methods for querying and setting of properties for a   //! resource.   //!   //! This default implementation takes care of the most important RFC   //! 2518 properties for ordinary files and directories in read-only   //! mode.   //!   //! Objects of this class are usually created through   //! @[RoxenModule()->query_properties()].    + #include <roxen.h> +    #ifdef DAV_DEBUG   #define DAV_WERROR(X...) werror(X)   #else /* !DAV_DEBUG */   #define DAV_WERROR(X...)   #endif /* DAV_DEBUG */    - //! Path for which these properties apply. + //! Filesystem-relative path for which these properties apply.   string path;    -  + //! Absolute path for which these properties apply. + string abs_path; +    //! The current request.   RequestID id;      //! Create a new property set.   //!   //! Usually called via @[query_properties()]. - static void create(string path, RequestID id) + static void create(string path, string abs_path, RequestID id)   {    global::path = path; -  +  global::abs_path = abs_path;    global::id = id; -  +  +  ASSERT_IF_DEBUG(has_prefix(abs_path, "/") && has_suffix(abs_path, path));   }      //! Destruction callback.   //!   //! Note that this function must unroll any uncommitted   //! property changes. - static void destroy() - { - } + static void destroy();      //! Return an @[Stdio.Stat] object for the resource. Its main use is   //! to tell collections (i.e. directories) from non-collections.   Stat get_stat();      //! Called by the default @[query_property] implementation to get the   //! response headers a GET or HEAD request on @[path] would yield.   //! It's used to fill in the properties that should reflect various   //! response headers.   mapping(string:string) get_response_headers();
Roxen.git/server/etc/modules/PropertySet.pike:286:    case "DAV:getcontenttype": // RFC2518 13.5    return get_response_headers()["Content-Type"];       case "DAV:getetag": // RFC2518 13.6    return get_response_headers()->ETag;       case "DAV:getlastmodified": // RFC2518 13.7    return get_response_headers()["Last-Modified"];       case "DAV:lockdiscovery": // RFC2518 13.8 -  return indices(id->conf->find_locks(path, 0, 0, id))->get_xml(); +  return indices(id->conf->find_locks(abs_path, 0, 0, id))->get_xml();       case "DAV:resourcetype": // RFC2518 13.9    if (get_stat()->isdir) {    return ({    Parser.XML.Tree.ElementNode("DAV:collection", ([])), // 12.2    });    }    return 0;       case "DAV:supportedlock": // RFC2518 13.11    {    array(Parser.XML.Tree.Node) res = ({    Parser.XML.Tree.ElementNode("DAV:lockentry", ([])),    Parser.XML.Tree.ElementNode("DAV:lockentry", ([])),    }); -  res->add_child(Parser.XML.Tree.ElementNode("DAV:lockscope", ([]))); -  res[0]->get_last_child()-> +  res[0]->add_child(Parser.XML.Tree.ElementNode("DAV:lockscope", ([])))->    add_child(Parser.XML.Tree.ElementNode("DAV:exclusive", ([]))); -  res[1]->get_last_child()-> -  add_child(Parser.XML.Tree.ElementNode("DAV:exclusive", ([]))); -  res->add_child(Parser.XML.Tree.ElementNode("DAV:locktype", ([])))-> +  res[1]->add_child(Parser.XML.Tree.ElementNode("DAV:lockscope", ([])))-> +  add_child(Parser.XML.Tree.ElementNode("DAV:shared", ([]))); +  res[0]->add_child(Parser.XML.Tree.ElementNode("DAV:locktype", ([])))->    add_child(Parser.XML.Tree.ElementNode("DAV:write", ([]))); -  +  res[1]->add_child(Parser.XML.Tree.ElementNode("DAV:locktype", ([])))-> +  add_child(Parser.XML.Tree.ElementNode("DAV:write", ([])));    return res;    }    case "http://apache.org/dav/props/executable":    // http://www.webdav.org/mod_dav/:    //    // Name: executable    // Namespace: http://apache.org/dav/props/    // Purpose: Describes the executable status of the resource.    // Value: "T" | "F" (case is significant)    // Description: This property is defined by mod_dav's default
Roxen.git/server/etc/modules/PropertySet.pike:367: Inside #if 0
   if (!(get_stat()->mode & 0222)) {    return "1";    }    return "0";    case "DAV:isroot": // MS    if (path == "") return "1";    return "0";    case "DAV:lastaccessed": // MS    return Roxen.iso8601_date_time(get_stat()->atime);    case "DAV:href": // MS -  return sprintf("%s://%s%s%s%s", -  id->port_obj->prot_name, -  id->misc->host || id->port_obj->ip || -  gethostname(), -  (id->port_obj->port == id->port_obj->port)? -  "":(":"+(string)id->port_obj->port), -  id->port_obj->path||"", -  combine_path(query_location(), path)); +  return id->url_base() + abs_path[1..];    case "DAV:contentclass": // MS    return "";    case "DAV:parentname": // MS    return "";    case "DAV:name": // MS -  return combine_path(query_location(), path); +  return abs_path;   #endif /* 0 */       default:    break;    }       DAV_WERROR("query_property(): Unimplemented property:%O\n", prop_name);    // RFC 2518 8.1:    // A request to retrieve the value of a property which does not    // exist is an error and MUST be noted, if the response uses a