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.
152
2004/03/01
19
:
26
:
42
grubba
Exp $
+
// $Id: module.pike,v 1.
153
2004/03/01
20
:
21
:
05
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:600:
return Roxen.http_low_answer(404, "No such property."); } //! Attempt to set property @[prop_name] for @[path] to @[value]. //! //! @param value //! Value to set the node to. //! The case of an array of a single text node is special cased, //! and is sent as a @expr{string@}. //!
+
//! @param context
+
//! The value returned by @[patch_property_start()].
+
//!
//! @returns //! Returns a result mapping. May return @expr{0@} (zero) on success. //! //! @note //! Actual changing of the property should be done first //! when @[patch_property_commit()] is called, or unrolled //! when @[patch_property_unroll()] is called. //! //! @note
-
//! Overloaded variants should only set live properties
;
-
//!
setting
of dead properties should be done
throuh
-
//!
overloading of
@[set_dead_property()].
+
//! Overloaded variants should only set
the
live properties
they can
+
//!
handle
and call the inherited implementation for all others.
+
//! Setting
of dead properties should be done
through overloading of
+
//! @[set_dead_property()].
This way, the live properties handled on
+
//! any level in the inherit hierachy take precedence over dead
+
//! properties.
+
//!
+
//! @note
+
//! RFC 2518: Live property - A property whose semantics and syntax
+
//! are enforced by the server. For example, the live
+
//! "getcontentlength" property has its value, the length of the
+
//! entity returned by a GET request, automatically calculated by
+
//! the server.
mapping(string:mixed) set_property(string path, string prop_name, string|array(Parser.XML.Tree.Node) value,
-
RequestID id)
+
RequestID id
, mixed context
)
{ switch(prop_name) { case "http://apache.org/dav/props/executable": // FIXME: Could probably be implemented R/W. // FALL_THROUGH case "DAV:displayname": // 13.2 case "DAV:getcontentlength": // 13.4 case "DAV:getcontenttype": // 13.5 case "DAV:getlastmodified": // 13.7 return Roxen.http_low_answer(409, "Attempt to set read-only property."); }
-
return set_dead_property(path, prop_name, value, id);
+
return set_dead_property(path, prop_name, value, id
, context
);
} //! Attempt to set dead property @[prop_name] for @[path] to @[value]. //!
-
+
//! @param context
+
//! The value returned by @[patch_property_start()].
+
//!
//! @returns //! Returns a result mapping. May return @expr{0@} (zero) on success. //! //! @note //! Actual changing of the property should be done first //! when @[patch_property_commit()] is called, or unrolled //! when @[patch_property_unroll()] is called. //! //! @note //! This function is called as a fallback by @[set_property()] //! if all else fails. //! //! @note //! The default implementation currently does not support setting //! of dead properties, and will return an error code.
-
+
//!
+
//! @note
+
//! RFC 2518: Dead Property - A property whose semantics and syntax
+
//! are not enforced by the server. The server only records the
+
//! value of a dead property; the client is responsible for
+
//! maintaining the consistency of the syntax and semantics of a
+
//! dead property.
mapping(string:mixed) set_dead_property(string path, string prop_name, array(Parser.XML.Tree.Node) value,
-
RequestID id)
+
RequestID id
, mixed context
)
{ return Roxen.http_low_answer(405, "Setting of dead properties is not supported."); } //! Attempt to remove the property @[prop_name] for @[path]. //!
-
+
//! @param context
+
//! The value returned by @[patch_property_start()].
+
//!
//! @note //! Actual removal of the property should be done first //! when @[patch_property_commit()] is called, or unrolled //! when @[patch_property_unroll()] is called. //! //! @returns //! Returns a result mapping. May return @expr{0@} (zero) on success. //! //! @note //! The default implementation does not support deletion. mapping(string:mixed) remove_property(string path, string prop_name,
-
RequestID id)
+
RequestID id
, mixed context
)
{ switch(prop_name) { case "http://apache.org/dav/props/executable": case "DAV:displayname": // 13.2 case "DAV:getcontentlength": // 13.4 case "DAV:getcontenttype": // 13.5 case "DAV:getlastmodified": // 13.7 return Roxen.http_low_answer(409, "Attempt to remove a read-only property."); }
Roxen.git/server/base_server/module.pike:805:
MultiStatus result, RequestID id) { mixed context = patch_property_start(path, id); array(mapping(string:mixed)) results; mixed err = catch { results = instructions->execute(path, this_object(), id, context); }; if (err) {
-
foreach(instructions, PatchPropertyCommand instr) {
-
result->add_property(path, instr->property_name, answer);
-
}
+
patch_property_unroll(path, id, context); throw (err); } else { int any_failed; foreach(results, mapping(string:mixed) answer) { if (any_failed = (answer && (answer->error >= 300))) { break; } } if (any_failed) {
Roxen.git/server/base_server/module.pike:843:
int i; for(i = 0; i < sizeof(results); i++) { result->add_property(path, instructions[i]->property_name, results[i]); } patch_property_commit(path, id, context); } } }
+
//! Convenience variant of @[set_property] that sets a single
+
//! property: The default implementation calls
+
//! @[patch_property_start], @[set_property], @[patch_property_unroll]
+
//! and @[patch_property_commit] as appropriate.
+
mapping(string:mixed) set_single_property (string path, string prop_name,
+
string|array(Parser.XML.Tree.Node) value,
+
RequestID id)
+
{
+
mixed context = patch_property_start(path, id);
+
mapping(string:mixed) result = set_property (path, prop_name, value, id, context);
+
if (result && result->error >= 300)
+
patch_property_unroll (path, id, context);
+
else
+
patch_property_commit (path, id, context);
+
return result;
+
}
+
+
//! Convenience variant of @[remove_property] that removes a single
+
//! property: The default implementation calls
+
//! @[patch_property_start], @[remove_property],
+
//! @[patch_property_unroll] and @[patch_property_commit] as
+
//! appropriate.
+
mapping(string:mixed) remove_single_property (string path, string prop_name,
+
RequestID id)
+
{
+
mixed context = patch_property_start(path, id);
+
mapping(string:mixed) result = remove_property (path, prop_name, id, context);
+
if (result && result->error >= 300)
+
patch_property_unroll (path, id, context);
+
else
+
patch_property_commit (path, id, context);
+
return result;
+
}
+
mapping copy_file(string path, string dest, int(-1..1) behavior, RequestID id) { werror("copy_file(%O, %O, %O, %O)\n", path, dest, behavior, id); return Roxen.http_low_answer(501, "Not implemented."); } void recurse_copy_files(string path, int depth, string dest_prefix, string dest_suffix, mapping(string:int(-1..1)) behavior,