Browse Source

added PUT, all basic litmus tests passed

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@589 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.2
Jan Kneschke 17 years ago
parent
commit
6c160ec7d9
  1. 3
      doc/webdav.txt
  2. 43
      src/mod_webdav.c

3
doc/webdav.txt

@ -30,11 +30,12 @@ So far we have
* OPTIONS
* MKCOL
* DELETE
* PUT
and the usual GET, POST, HEAD from HTTP/1.1.
So far mounting a webdav resource into Windows XP works and the basic litmus
tests are passed (excluding PUT as it is not implemented).
tests are passed.
Options
=======

43
src/mod_webdav.c

@ -6,6 +6,7 @@
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "base.h"
#include "log.h"
@ -426,7 +427,10 @@ URIHANDLER_FUNC(mod_webdav_subrequest_handler) {
return HANDLER_FINISHED;
case HTTP_METHOD_MKCOL:
if (p->conf.is_readonly) break;
if (p->conf.is_readonly) {
con->http_status = 403;
return HANDLER_FINISHED;
}
if (con->request.content_length != 0) {
/* we don't support MKCOL with a body */
@ -457,8 +461,11 @@ URIHANDLER_FUNC(mod_webdav_subrequest_handler) {
return HANDLER_FINISHED;
case HTTP_METHOD_DELETE:
if (p->conf.is_readonly) break;
if (p->conf.is_readonly) {
con->http_status = 403;
return HANDLER_FINISHED;
}
/* stat and unlink afterwards */
if (-1 == stat(con->physical.path->ptr, &st)) {
/* don't about it yet, unlink will fail too */
@ -523,6 +530,36 @@ URIHANDLER_FUNC(mod_webdav_subrequest_handler) {
con->http_status = 204;
}
return HANDLER_FINISHED;
case HTTP_METHOD_PUT: {
int fd;
if (p->conf.is_readonly) {
con->http_status = 403;
return HANDLER_FINISHED;
}
/* taken what we have in the request-body and write it to a file */
if (-1 == (fd = open(con->physical.path->ptr, O_WRONLY|O_CREAT|O_TRUNC, 0600))) {
/* we can't open the file */
con->http_status = 403;
} else {
con->http_status = 201; /* created */
if (-1 == (write(fd, con->request.content->ptr, con->request.content->used - 1))) {
switch(errno) {
case ENOSPC:
con->http_status = 507;
break;
default:
con->http_status = 403;
break;
}
}
close(fd);
}
return HANDLER_FINISHED;
}
default:
break;
}

Loading…
Cancel
Save