[mod_webdav] alt handling PROPFIND on collection

alternative way of handling PROPFIND on collection where the request was
made without a trailing slash.  Instead of sending 308 redirect in some
cases, set Content-Location response header *and* treat as if request
had been made with trailing slash on the collection for PROPFIND and
PROPPATCH.

https://www.rfc-editor.org/rfc/rfc4918#section-5.2
  There is a standing convention that when a collection is referred to
  by its name without a trailing slash, the server MAY handle the
  request as if the trailing slash were present. In this case, it
  SHOULD return a Content-Location header in the response, pointing to
  the URL ending with the "/".

x-ref:
  "The previous workaround for GVFS is breaking the new version of GVFS"
  https://redmine.lighttpd.net/boards/2/topics/10468
  HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)
  https://www.rfc-editor.org/rfc/rfc4918#section-5.2
master
Glenn Strauss 6 months ago
parent 5c4cc9f567
commit def1bfa976
  1. 37
      src/mod_webdav.c

@ -4186,24 +4186,8 @@ mod_webdav_propfind (request_st * const r, const plugin_config * const pconf)
}
else if (S_ISDIR(pb.st.st_mode)) {
if (!buffer_has_pathsep_suffix(&r->physical.path)) {
const buffer *vb =
http_header_request_get(r, HTTP_HEADER_USER_AGENT,
CONST_STR_LEN("User-Agent"));
if (vb && 0 == strncmp(vb->ptr, "Microsoft-WebDAV-MiniRedir/",
sizeof("Microsoft-WebDAV-MiniRedir/")-1)) {
/* workaround Microsoft-WebDAV-MiniRedir bug */
/* (MS File Explorer unable to open folder if not redirected) */
http_response_redirect_to_directory(r, 308);
return HANDLER_FINISHED;
}
if (vb && 0 == strncmp(vb->ptr, "gvfs/", sizeof("gvfs/")-1)) {
/* workaround gvfs bug */
/* (gvfs unable to open folder if not redirected) */
http_response_redirect_to_directory(r, 308);
return HANDLER_FINISHED;
}
/* set "Content-Location" instead of sending 308 redirect to dir */
if (!http_response_redirect_to_directory(r, 0))
if (0 != http_response_redirect_to_directory(r, 0))
return HANDLER_FINISHED;
buffer_append_char(&r->physical.path, '/');
buffer_append_char(&r->physical.rel_path, '/');
@ -5404,25 +5388,8 @@ mod_webdav_proppatch (request_st * const r, const plugin_config * const pconf)
if (S_ISDIR(st.st_mode)) {
if (!buffer_has_pathsep_suffix(&r->physical.path)) {
const buffer *vb =
http_header_request_get(r, HTTP_HEADER_USER_AGENT,
CONST_STR_LEN("User-Agent"));
if (vb && 0 == strncmp(vb->ptr, "Microsoft-WebDAV-MiniRedir/",
sizeof("Microsoft-WebDAV-MiniRedir/")-1)) {
/* workaround Microsoft-WebDAV-MiniRedir bug */
/* (might not be necessary for PROPPATCH here,
* but match behavior in mod_webdav_propfind() for PROPFIND) */
http_response_redirect_to_directory(r, 308);
return HANDLER_FINISHED;
}
if (vb && 0 == strncmp(vb->ptr, "gvfs/", sizeof("gvfs/")-1)) {
/* workaround gvfs bug */
/* (gvfs unable to open folder if not redirected) */
http_response_redirect_to_directory(r, 308);
return HANDLER_FINISHED;
}
/* set "Content-Location" instead of sending 308 redirect to dir */
if (!http_response_redirect_to_directory(r, 0))
if (0 != http_response_redirect_to_directory(r, 0))
return HANDLER_FINISHED;
buffer_append_char(&r->physical.path, '/');
buffer_append_char(&r->physical.rel_path, '/');

Loading…
Cancel
Save