Branch: Tag:

2004-03-03

2004-03-03 17:36:07 by Martin Stjernholm <mast@lysator.liu.se>

Use http_status and the rettext field in status mappings for webdav to avoid
html quoting confusion.

Rev: server/base_server/module.pike:1.155
Rev: server/base_server/prototypes.pike:1.73

1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2001, Roxen IS. - // $Id: module.pike,v 1.154 2004/03/03 16:25:24 grubba Exp $ + // $Id: module.pike,v 1.155 2004/03/03 17:36:06 mast Exp $      #include <module_constants.h>   #include <module.h>
475:   //! Returns the value of the specified property, or an error code   //! mapping.   //! + //! The default implementation takes care of the most important RFC + //! 2518 properties. + //!   //! @param st   //! If set, this should be the stat that corresponds to @[path]. Its   //! only purpose is to save a call to @[stat_file] when the stat
489:    if (!st) {    st = stat_file(path, id);    if (!st) -  return Roxen.http_low_answer(404, "No such file or directory."); +  return Roxen.http_status (Protocols.HTTP.HTTP_NOT_FOUND, +  "No such file or directory.");    }    switch(prop_name) {    case "DAV:creationdate": // RFC2518 13.1
597:    // exist is an error and MUST be noted, if the response uses a    // multistatus XML element, with a response XML element which    // contains a 404 (Not Found) status value. -  return Roxen.http_low_answer(404, "No such property."); +  return Roxen.http_status (Protocols.HTTP.HTTP_NOT_FOUND, "No such property.");   }      //! Attempt to set property @[prop_name] for @[path] to @[value].
644:    case "DAV:getcontentlength": // 13.4    case "DAV:getcontenttype": // 13.5    case "DAV:getlastmodified": // 13.7 -  return Roxen.http_low_answer(409, +  return Roxen.http_status (Protocols.HTTP.HTTP_CONFLICT,    "Attempt to set read-only property.");    }    return set_dead_property(path, prop_name, value, id, context);
681:    array(Parser.XML.Tree.Node) value,    RequestID id, mixed context)   { -  return Roxen.http_low_answer(405, +  return Roxen.http_status (Protocols.HTTP.HTTP_METHOD_INVALID,    "Setting of dead properties is not supported.");   }   
709:    case "DAV:getcontentlength": // 13.4    case "DAV:getcontenttype": // 13.5    case "DAV:getlastmodified": // 13.7 -  return Roxen.http_low_answer(409, +  return Roxen.http_status (Protocols.HTTP.HTTP_CONFLICT,    "Attempt to remove a read-only property.");    }    // RFC 2518 12.13.1:
718:    return 0;   }    - //! Default implementation of some RFC 2518 properties. + //! RFC 2518 PROPFIND implementation for a single resource (i.e. not + //! recursive).   //!   //! @param path   //! @[query_location()]-relative path.   //! @param mode - //! Query-mode. Currently one of + //! Query mode. Currently one of   //! @string mode   //! @value "DAV:propname" - //! Query after names of supported properties. + //! Query names of supported properties.   //! @value "DAV:allprop" - //! Query after all properties and their values. + //! Query all properties and their values.   //! @value "DAV:prop" - //! Query after properties specified by @[filt] and - //! their values. + //! Query properties specified by @[filt] and their values.   //! @endstring   //! @param result   //! Result object.
782:    return 0;   }    + //! RFC 2518 PROPFIND implementation with recursion according to + //! @[depth]. See @[find_properties] for details.   void recurse_find_properties(string path, string mode,    int depth, MultiStatus result,    RequestID id,
799:    find_properties(path, mode, result, id, filt, st);    if (ret) {    result->add_response(path, XMLStatusNode(ret->error)); +  if (ret->rettext) { +  Parser.XML.Tree.ElementNode descr = +  Parser.XML.Tree.ElementNode ("DAV:responsedescription", ([])); +  descr->add_child (Parser.XML.Tree.TextNode (ret->rettext)); +  result->add_response (path, descr); +  }    return;    }    if ((depth <= 0) || !st->isdir) return;
876:    // Unroll and fail any succeeded items.    int i;    mapping(string:mixed) answer = -  Roxen.http_low_answer(424, "Failed dependency."); +  Roxen.http_status (Protocols.HTTP.DAV_FAILED_DEP, "Failed dependency.");    for(i = 0; i < sizeof(results); i++) {    if (!results[i] || results[i]->error < 300) {    result->add_property(path, instructions[i]->property_name,
937:   {    werror("copy_file(%O, %O, %O, %O)\n",    path, dest, behavior, id); -  return Roxen.http_low_answer(501, "Not implemented."); +  return Roxen.http_status (Protocols.HTTP.HTTP_NOT_IMPL);   }      void recurse_copy_files(string path, int depth, string dest_prefix,