Branch: Tag:

2018-03-21

2018-03-21 16:24:01 by Henrik Grubbström (Grubba) <grubba@grubba.org>

RoxenModule [WebDAV]: Fixed multiple issues in copy_collection.

RFC 4918 9.8.5 says that eg 423 is a valid direct return code
for COPY if the destination was locked. Previously this code
was embedded in a multi-status reply for the corresponding path.

Return 204 if a preexisting resource was overwritten by the
copy operation.

Fixes issue related to [WS-222].

1671: Inside #if 0
   // to the client.   #if 0    return Roxen.http_status(Protocols.HTTP.HTTP_PRECOND_FAILED); - #else + #elif 0    if (sizeof (res)) {    // RFC 2518 8.8.3:    // If an error in executing the COPY method occurs with a
1684:    result->add_status (destination, res->error, res->rettext);    }    return ([]); + #else +  // RFC 4918 9.8.5: +  // 423 (Locked) - The destination resource, or resource +  // within the destination collection, was locked. This +  // response SHOULD contain the 'lock-token-submitted' +  // precondition element. +  return res;   #endif    }    TRACE_LEAVE("Deletion ok.");
1699:    return copy_properties(source, destination, behavior, id);    }    TRACE_LEAVE("Destination exists and is not a directory."); -  return Roxen.http_status(Protocols.HTTP.HTTP_PRECOND_FAILED); +  return Roxen.http_status(Protocols.HTTP.HTTP_CONFLICT);    }    }    // Create the new collection.    TRACE_LEAVE("Make a new collection.");    mapping(string:mixed) res = make_collection(destination, id);    if (res && res->error >= 300) return res; -  return copy_properties(source, destination, behavior, id) || res; +  res = copy_properties(source, destination, behavior, id) || res; +  if (res && st && (res->error == Protocols.HTTP.HTTP_CREATED)) { +  // RFC 4918 9.8.5: +  // 204 (No Content) - The source resource was successfully +  // copied to a preexisting destination resource. +  res->error = Protocols.HTTP.HTTP_NO_CONTENT;    } -  +  return res; + }      //! Used by the default @[recurse_copy_files] to copy a single file   //! along with its properties.