| CODENOTIFIER | HelpYou are not signed inSign in |
Project: lighttpd
Revision: 2268
Author: stbuehler
Date: 01 Aug 2008 06:07:25
Changes:Fixed mod_webdav, litmus now passes everything except locks (#1738)
3 warnings in litmus 0.11:
* "DELETE removed collection resource with Request-URI including fragment; unsafe" - i don't care about that :)
* 2x"{COPY, MOVE} to existing collection resource didn't give 204" - bug in litmus
| ... | ...@@ -493,6 +493,57 @@ | |
| 493 | 493 | |
| 494 | 494 | return HANDLER_GO_ON; |
| 495 | 495 | } |
| 496 | ||
| 497 | PHYSICALPATH_FUNC(mod_webdav_physical_handler) { | |
| 498 | plugin_data *p = p_d; | |
| 499 | ||
| 500 | if (con->mode != DIRECT) return HANDLER_GO_ON; | |
| 501 | ||
| 502 | mod_webdav_patch_connection(srv, con, p); | |
| 503 | ||
| 504 | if (!p->conf.enabled) { | |
| 505 | if (con->conf.log_request_handling) { | |
| 506 | TRACE("-- skipping %s in mod_webdav, not enabled", | |
| 507 | SAFE_BUF_STR(con->uri.path)); | |
| 508 | } | |
| 509 | ||
| 510 | return HANDLER_GO_ON; | |
| 511 | } | |
| 512 | ||
| 513 | if (con->conf.log_request_handling) { | |
| 514 | TRACE("-- handling request in mod_webdav: %s", | |
| 515 | SAFE_BUF_STR(con->uri.path)); | |
| 516 | } | |
| 517 | ||
| 518 | /* physical path is setup */ | |
| 519 | if (con->physical.path->used == 0) { | |
| 520 | TRACE("-- missing con->physical.path: %s", | |
| 521 | SAFE_BUF_STR(con->uri.path)); | |
| 522 | return HANDLER_GO_ON; | |
| 523 | } | |
| 524 | ||
| 525 | switch (con->request.http_method) { | |
| 526 | case HTTP_METHOD_OPTIONS: | |
| 527 | /* already handled */ | |
| 528 | break; | |
| 529 | case HTTP_METHOD_PROPFIND: | |
| 530 | case HTTP_METHOD_MKCOL: | |
| 531 | case HTTP_METHOD_DELETE: | |
| 532 | case HTTP_METHOD_PUT: | |
| 533 | case HTTP_METHOD_MOVE: | |
| 534 | case HTTP_METHOD_COPY: | |
| 535 | case HTTP_METHOD_PROPPATCH: | |
| 536 | case HTTP_METHOD_LOCK: | |
| 537 | case HTTP_METHOD_UNLOCK: | |
| 538 | con->mode = p->id; | |
| 539 | return HANDLER_FINISHED; | |
| 540 | default: break; | |
| 541 | } | |
| 542 | ||
| 543 | return HANDLER_GO_ON; | |
| 544 | } | |
| 545 | ||
| 546 | ||
| 496 | 547 | static int webdav_gen_prop_tag(server *srv, connection *con, |
| 497 | 548 | char *prop_name, |
| 498 | 549 | char *prop_ns, |
| ... | ...@@ -573,10 +624,7 @@ | |
| 573 | 624 | #ifdef USE_PROPPATCH |
| 574 | 625 | sqlite3_stmt *stmt = p->conf.stmt_delete_uri; |
| 575 | 626 | |
| 576 | if (!stmt) { | |
| 577 | status = 403; | |
| 578 | webdav_gen_response_status_tag(srv, con, dst, status, b); | |
| 579 | } else { | |
| 627 | if (stmt) { | |
| 580 | 628 | sqlite3_reset(stmt); |
| 581 | 629 | |
| 582 | 630 | /* bind the values to the insert */ |
| ... | ...@@ -1238,14 +1286,10 @@ | |
| 1238 | 1286 | stat_cache_entry *sce = NULL; |
| 1239 | 1287 | |
| 1240 | 1288 | if (con->conf.log_request_handling) { |
| 1241 | TRACE("-- handling request in mod_webdav: %s", | |
| 1289 | TRACE("-- handling request in mod_webdav: %s", | |
| 1242 | 1290 | SAFE_BUF_STR(con->uri.path)); |
| 1243 | 1291 | } |
| 1244 | 1292 | |
| 1245 | if (!p->conf.enabled) return HANDLER_GO_ON; | |
| 1246 | /* physical path is setup */ | |
| 1247 | if (con->physical.path->used == 0) return HANDLER_GO_ON; | |
| 1248 | ||
| 1249 | 1293 | /* PROPFIND need them */ |
| 1250 | 1294 | if (NULL != (ds = (data_string *)array_get_element(con->request.headers, CONST_STR_LEN("Depth")))) { |
| 1251 | 1295 | depth = strtol(ds->value->ptr, NULL, 10); |
| ... | ...@@ -1281,6 +1325,7 @@ | |
| 1281 | 1325 | } |
| 1282 | 1326 | |
| 1283 | 1327 | con->http_status = 404; |
| 1328 | con->mode = DIRECT; | |
| 1284 | 1329 | return HANDLER_FINISHED; |
| 1285 | 1330 | } |
| 1286 | 1331 | break; |
| ... | ...@@ -1291,7 +1336,7 @@ | |
| 1291 | 1336 | |
| 1292 | 1337 | #ifdef USE_PROPPATCH |
| 1293 | 1338 | /* any special requests or just allprop ? */ |
| 1294 | if (con->request.content_length) { | |
| 1339 | if (p->conf.sql && con->request.content_length > 0) { | |
| 1295 | 1340 | xmlDocPtr xml; |
| 1296 | 1341 | |
| 1297 | 1342 | if (1 == webdav_parse_chunkqueue(srv, con, p, con->recv, &xml)) { |
| ... | ...@@ -1331,6 +1376,7 @@ | |
| 1331 | 1376 | free(req_props); |
| 1332 | 1377 | |
| 1333 | 1378 | con->http_status = 400; |
| 1379 | con->mode = DIRECT; | |
| 1334 | 1380 | return HANDLER_FINISHED; |
| 1335 | 1381 | } |
| 1336 | 1382 | |
| ... | ...@@ -1375,6 +1421,7 @@ | |
| 1375 | 1421 | ERROR("webdav_parse_chunkqueue() failed: %s", ""); |
| 1376 | 1422 | |
| 1377 | 1423 | con->http_status = 400; |
| 1424 | con->mode = DIRECT; | |
| 1378 | 1425 | return HANDLER_FINISHED; |
| 1379 | 1426 | } |
| 1380 | 1427 | } |
| ... | ...@@ -1540,12 +1587,14 @@ | |
| 1540 | 1587 | case HTTP_METHOD_MKCOL: |
| 1541 | 1588 | if (p->conf.is_readonly) { |
| 1542 | 1589 | con->http_status = 403; |
| 1590 | con->mode = DIRECT; | |
| 1543 | 1591 | return HANDLER_FINISHED; |
| 1544 | 1592 | } |
| 1545 | 1593 | |
| 1546 | if (con->request.content_length != 0) { | |
| 1594 | if (con->request.content_length > 0) { | |
| 1547 | 1595 | /* we don't support MKCOL with a body */ |
| 1548 | 1596 | con->http_status = 415; |
| 1597 | con->mode = DIRECT; | |
| 1549 | 1598 | |
| 1550 | 1599 | return HANDLER_FINISHED; |
| 1551 | 1600 | } |
| ... | ...@@ -1566,6 +1615,7 @@ | |
| 1566 | 1615 | con->http_status = 405; /* not allowed */ |
| 1567 | 1616 | break; |
| 1568 | 1617 | } |
| 1618 | con->mode = DIRECT; | |
| 1569 | 1619 | } else { |
| 1570 | 1620 | con->http_status = 201; |
| 1571 | 1621 | con->send->is_closed = 1; |
| ... | ...@@ -1575,12 +1625,14 @@ | |
| 1575 | 1625 | case HTTP_METHOD_DELETE: |
| 1576 | 1626 | if (p->conf.is_readonly) { |
| 1577 | 1627 | con->http_status = 403; |
| 1628 | con->mode = DIRECT; | |
| 1578 | 1629 | return HANDLER_FINISHED; |
| 1579 | 1630 | } |
| 1580 | 1631 | |
| 1581 | 1632 | /* does the client have a lock for this connection ? */ |
| 1582 | 1633 | if (!webdav_has_lock(srv, con, p, con->uri.path)) { |
| 1583 | 1634 | con->http_status = 423; |
| 1635 | con->mode = DIRECT; | |
| 1584 | 1636 | return HANDLER_FINISHED; |
| 1585 | 1637 | } |
| 1586 | 1638 | |
| ... | ...@@ -1595,6 +1647,7 @@ | |
| 1595 | 1647 | con->http_status = 403; |
| 1596 | 1648 | break; |
| 1597 | 1649 | } |
| 1650 | con->mode = DIRECT; | |
| 1598 | 1651 | } else if (S_ISDIR(st.st_mode)) { |
| 1599 | 1652 | buffer *multi_status_resp = buffer_init(); |
| 1600 | 1653 | |
| ... | ...@@ -1630,8 +1683,10 @@ | |
| 1630 | 1683 | con->http_status = 501; |
| 1631 | 1684 | break; |
| 1632 | 1685 | } |
| 1686 | con->mode = DIRECT; | |
| 1633 | 1687 | } else { |
| 1634 | 1688 | con->http_status = 204; |
| 1689 | con->send->is_closed = 1; | |
| 1635 | 1690 | } |
| 1636 | 1691 | } |
| 1637 | 1692 | |
| ... | ...@@ -1648,8 +1703,10 @@ | |
| 1648 | 1703 | con->http_status = 501; |
| 1649 | 1704 | break; |
| 1650 | 1705 | } |
| 1706 | con->mode = DIRECT; | |
| 1651 | 1707 | } else { |
| 1652 | 1708 | con->http_status = 204; |
| 1709 | con->send->is_closed = 1; | |
| 1653 | 1710 | } |
| 1654 | 1711 | return HANDLER_FINISHED; |
| 1655 | 1712 | case HTTP_METHOD_PUT: { |
| ... | ...@@ -1660,17 +1717,24 @@ | |
| 1660 | 1717 | |
| 1661 | 1718 | if (p->conf.is_readonly) { |
| 1662 | 1719 | con->http_status = 403; |
| 1720 | con->mode = DIRECT; | |
| 1663 | 1721 | return HANDLER_FINISHED; |
| 1664 | 1722 | } |
| 1665 | 1723 | |
| 1666 | 1724 | /* is a exclusive lock set on the source */ |
| 1667 | 1725 | if (!webdav_has_lock(srv, con, p, con->uri.path)) { |
| 1668 | 1726 | con->http_status = 423; |
| 1727 | con->mode = DIRECT; | |
| 1669 | 1728 | return HANDLER_FINISHED; |
| 1670 | 1729 | } |
| 1671 | 1730 | |
| 1672 | 1731 | |
| 1673 | assert(chunkqueue_length(cq) == (off_t)con->request.content_length); | |
| 1732 | if (chunkqueue_length(cq) != (off_t)con->request.content_length) { | |
| 1733 | ERROR("%s", "chunkqueue_length didn't match request.content_length"); | |
| 1734 | con->http_status = 500; | |
| 1735 | con->mode = DIRECT; | |
| 1736 | return HANDLER_FINISHED; | |
| 1737 | } | |
| 1674 | 1738 | |
| 1675 | 1739 | /* RFC2616 Section 9.6 PUT requires us to send 501 on all Content-* we don't support |
| 1676 | 1740 | * - most important Content-Range |
| ... | ...@@ -1685,6 +1749,7 @@ | |
| 1685 | 1749 | |
| 1686 | 1750 | if (0 != strncmp(num, "bytes ", 6)) { |
| 1687 | 1751 | con->http_status = 501; /* not implemented */ |
| 1752 | con->mode = DIRECT; | |
| 1688 | 1753 | |
| 1689 | 1754 | return HANDLER_FINISHED; |
| 1690 | 1755 | } |
| ... | ...@@ -1698,6 +1763,7 @@ | |
| 1698 | 1763 | |
| 1699 | 1764 | if (*num == '\0') { |
| 1700 | 1765 | con->http_status = 501; /* not implemented */ |
| 1766 | con->mode = DIRECT; | |
| 1701 | 1767 | |
| 1702 | 1768 | return HANDLER_FINISHED; |
| 1703 | 1769 | } |
| ... | ...@@ -1710,12 +1776,14 @@ | |
| 1710 | 1776 | * conversion did a over- or underrun |
| 1711 | 1777 | */ |
| 1712 | 1778 | con->http_status = 501; /* not implemented */ |
| 1779 | con->mode = DIRECT; | |
| 1713 | 1780 | |
| 1714 | 1781 | return HANDLER_FINISHED; |
| 1715 | 1782 | } |
| 1716 | 1783 | |
| 1717 | 1784 | if (*err != '-' || offset < 0) { |
| 1718 | 1785 | con->http_status = 501; /* not implemented */ |
| 1786 | con->mode = DIRECT; | |
| 1719 | 1787 | |
| 1720 | 1788 | return HANDLER_FINISHED; |
| 1721 | 1789 | } |
| ... | ...@@ -1729,11 +1797,13 @@ | |
| 1729 | 1797 | con->http_status = 403; /* not found */ |
| 1730 | 1798 | break; |
| 1731 | 1799 | } |
| 1800 | con->mode = DIRECT; | |
| 1732 | 1801 | return HANDLER_FINISHED; |
| 1733 | 1802 | } |
| 1734 | 1803 | |
| 1735 | 1804 | if (-1 == lseek(fd, offset, SEEK_SET)) { |
| 1736 | 1805 | con->http_status = 501; /* not implemented */ |
| 1806 | con->mode = DIRECT; | |
| 1737 | 1807 | |
| 1738 | 1808 | close(fd); |
| 1739 | 1809 | |
| ... | ...@@ -1749,6 +1819,7 @@ | |
| 1749 | 1819 | -1 == (fd = open(con->physical.path->ptr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, WEBDAV_FILE_MODE))) { |
| 1750 | 1820 | /* we can't open the file */ |
| 1751 | 1821 | con->http_status = 403; |
| 1822 | con->mode = DIRECT; | |
| 1752 | 1823 | |
| 1753 | 1824 | return HANDLER_FINISHED; |
| 1754 | 1825 | } else { |
| ... | ...@@ -1840,6 +1911,7 @@ | |
| 1840 | 1911 | |
| 1841 | 1912 | if (p->conf.is_readonly) { |
| 1842 | 1913 | con->http_status = 403; |
| 1914 | con->mode = DIRECT; | |
| 1843 | 1915 | return HANDLER_FINISHED; |
| 1844 | 1916 | } |
| 1845 | 1917 | |
| ... | ...@@ -1847,6 +1919,7 @@ | |
| 1847 | 1919 | if (con->request.http_method == HTTP_METHOD_MOVE) { |
| 1848 | 1920 | if (!webdav_has_lock(srv, con, p, con->uri.path)) { |
| 1849 | 1921 | con->http_status = 423; |
| 1922 | con->mode = DIRECT; | |
| 1850 | 1923 | return HANDLER_FINISHED; |
| 1851 | 1924 | } |
| 1852 | 1925 | } |
| ... | ...@@ -1855,6 +1928,7 @@ | |
| 1855 | 1928 | destination = ds->value; |
| 1856 | 1929 | } else { |
| 1857 | 1930 | con->http_status = 400; |
| 1931 | con->mode = DIRECT; | |
| 1858 | 1932 | return HANDLER_FINISHED; |
| 1859 | 1933 | } |
| 1860 | 1934 | |
| ... | ...@@ -1863,6 +1937,7 @@ | |
| 1863 | 1937 | (ds->value->ptr[0] != 'F' && |
| 1864 | 1938 | ds->value->ptr[0] != 'T') ) { |
| 1865 | 1939 | con->http_status = 400; |
| 1940 | con->mode = DIRECT; | |
| 1866 | 1941 | return HANDLER_FINISHED; |
| 1867 | 1942 | } |
| 1868 | 1943 | overwrite = (ds->value->ptr[0] == 'F' ? 0 : 1); |
| ... | ...@@ -1884,6 +1959,7 @@ | |
| 1884 | 1959 | |
| 1885 | 1960 | if (NULL == (sep = strstr(start, "://"))) { |
| 1886 | 1961 | con->http_status = 400; |
| 1962 | con->mode = DIRECT; | |
| 1887 | 1963 | return HANDLER_FINISHED; |
| 1888 | 1964 | } |
| 1889 | 1965 | buffer_copy_string_len(p->uri.scheme, start, sep - start); |
| ... | ...@@ -1892,6 +1968,7 @@ | |
| 1892 | 1968 | |
| 1893 | 1969 | if (NULL == (sep = strchr(start, '/'))) { |
| 1894 | 1970 | con->http_status = 400; |
| 1971 | con->mode = DIRECT; | |
| 1895 | 1972 | return HANDLER_FINISHED; |
| 1896 | 1973 | } |
| 1897 | 1974 | buffer_copy_string_len(p->uri.authority, start, sep - start); |
| ... | ...@@ -1908,6 +1985,7 @@ | |
| 1908 | 1985 | if (!buffer_is_equal(p->uri.authority, con->uri.authority)) { |
| 1909 | 1986 | /* not the same host */ |
| 1910 | 1987 | con->http_status = 502; |
| 1988 | con->mode = DIRECT; | |
| 1911 | 1989 | return HANDLER_FINISHED; |
| 1912 | 1990 | } |
| 1913 | 1991 | |
| ... | ...@@ -1947,24 +2025,31 @@ | |
| 1947 | 2025 | con->http_status = 403; |
| 1948 | 2026 | break; |
| 1949 | 2027 | } |
| 2028 | con->mode = DIRECT; | |
| 1950 | 2029 | } else if (S_ISDIR(st.st_mode)) { |
| 1951 | 2030 | int r; |
| 1952 | 2031 | /* src is a directory */ |
| 1953 | 2032 | |
| 2033 | con->http_status = 204; | |
| 2034 | con->send->is_closed = 1; | |
| 1954 | 2035 | if (-1 == stat(p->physical.path->ptr, &st)) { |
| 1955 | 2036 | if (-1 == mkdir(p->physical.path->ptr, WEBDAV_DIR_MODE)) { |
| 1956 | 2037 | con->http_status = 403; |
| 2038 | con->mode = DIRECT; | |
| 1957 | 2039 | return HANDLER_FINISHED; |
| 1958 | 2040 | } |
| 2041 | con->http_status = 201; | |
| 1959 | 2042 | } else if (!S_ISDIR(st.st_mode)) { |
| 1960 | 2043 | if (overwrite == 0) { |
| 1961 | 2044 | /* copying into a non-dir ? */ |
| 1962 | 2045 | con->http_status = 409; |
| 2046 | con->mode = DIRECT; | |
| 1963 | 2047 | return HANDLER_FINISHED; |
| 1964 | 2048 | } else { |
| 1965 | 2049 | unlink(p->physical.path->ptr); |
| 1966 | 2050 | if (-1 == mkdir(p->physical.path->ptr, WEBDAV_DIR_MODE)) { |
| 1967 | 2051 | con->http_status = 403; |
| 2052 | con->mode = DIRECT; | |
| 1968 | 2053 | return HANDLER_FINISHED; |
| 1969 | 2054 | } |
| 1970 | 2055 | } |
| ... | ...@@ -1973,6 +2058,7 @@ | |
| 1973 | 2058 | /* copy the content of src to dest */ |
| 1974 | 2059 | if (0 != (r = webdav_copy_dir(srv, con, p, &(con->physical), &(p->physical), overwrite))) { |
| 1975 | 2060 | con->http_status = r; |
| 2061 | con->mode = DIRECT; | |
| 1976 | 2062 | return HANDLER_FINISHED; |
| 1977 | 2063 | } |
| 1978 | 2064 | if (con->request.http_method == HTTP_METHOD_MOVE) { |
| ... | ...@@ -1982,8 +2068,6 @@ | |
| 1982 | 2068 | |
| 1983 | 2069 | rmdir(con->physical.path->ptr); |
| 1984 | 2070 | } |
| 1985 | con->http_status = 201; | |
| 1986 | con->send->is_closed = 1; | |
| 1987 | 2071 | } else { |
| 1988 | 2072 | /* it is just a file, good */ |
| 1989 | 2073 | int r; |
| ... | ...@@ -1991,6 +2075,7 @@ | |
| 1991 | 2075 | /* does the client have a lock for this connection ? */ |
| 1992 | 2076 | if (!webdav_has_lock(srv, con, p, p->uri.path)) { |
| 1993 | 2077 | con->http_status = 423; |
| 2078 | con->mode = DIRECT; | |
| 1994 | 2079 | return HANDLER_FINISHED; |
| 1995 | 2080 | } |
| 1996 | 2081 | |
| ... | ...@@ -2014,14 +2099,17 @@ | |
| 2014 | 2099 | switch(errno) { |
| 2015 | 2100 | case ENOTDIR: |
| 2016 | 2101 | con->http_status = 409; |
| 2102 | con->mode = DIRECT; | |
| 2017 | 2103 | return HANDLER_FINISHED; |
| 2018 | 2104 | } |
| 2019 | 2105 | } else if (overwrite == 0) { |
| 2020 | 2106 | /* destination exists, but overwrite is not set */ |
| 2021 | 2107 | con->http_status = 412; |
| 2108 | con->mode = DIRECT; | |
| 2022 | 2109 | return HANDLER_FINISHED; |
| 2023 | 2110 | } else { |
| 2024 | 2111 | con->http_status = 204; /* resource already existed */ |
| 2112 | con->send->is_closed = 1; | |
| 2025 | 2113 | } |
| 2026 | 2114 | |
| 2027 | 2115 | if (con->request.http_method == HTTP_METHOD_MOVE) { |
| ... | ...@@ -2059,6 +2147,7 @@ | |
| 2059 | 2147 | |
| 2060 | 2148 | if (0 != (r = webdav_copy_file(srv, con, p, &(con->physical), &(p->physical), overwrite))) { |
| 2061 | 2149 | con->http_status = r; |
| 2150 | con->mode = DIRECT; | |
| 2062 | 2151 | |
| 2063 | 2152 | return HANDLER_FINISHED; |
| 2064 | 2153 | } |
| ... | ...@@ -2075,11 +2164,13 @@ | |
| 2075 | 2164 | case HTTP_METHOD_PROPPATCH: |
| 2076 | 2165 | if (p->conf.is_readonly) { |
| 2077 | 2166 | con->http_status = 403; |
| 2167 | con->mode = DIRECT; | |
| 2078 | 2168 | return HANDLER_FINISHED; |
| 2079 | 2169 | } |
| 2080 | 2170 | |
| 2081 | 2171 | if (!webdav_has_lock(srv, con, p, con->uri.path)) { |
| 2082 | 2172 | con->http_status = 423; |
| 2173 | con->mode = DIRECT; | |
| 2083 | 2174 | return HANDLER_FINISHED; |
| 2084 | 2175 | } |
| 2085 | 2176 | |
| ... | ...@@ -2088,12 +2179,13 @@ | |
| 2088 | 2179 | switch(errno) { |
| 2089 | 2180 | case ENOENT: |
| 2090 | 2181 | con->http_status = 404; |
| 2182 | con->mode = DIRECT; | |
| 2091 | 2183 | break; |
| 2092 | 2184 | } |
| 2093 | 2185 | } |
| 2094 | 2186 | |
| 2095 | 2187 | #ifdef USE_PROPPATCH |
| 2096 | if (con->request.content_length) { | |
| 2188 | if (p->conf.sql && con->request.content_length > 0) { | |
| 2097 | 2189 | xmlDocPtr xml; |
| 2098 | 2190 | |
| 2099 | 2191 | if (1 == webdav_parse_chunkqueue(srv, con, p, con->recv, &xml)) { |
| ... | ...@@ -2193,6 +2285,7 @@ | |
| 2193 | 2285 | } |
| 2194 | 2286 | |
| 2195 | 2287 | con->http_status = 400; |
| 2288 | con->mode = DIRECT; | |
| 2196 | 2289 | } else { |
| 2197 | 2290 | if (SQLITE_OK != sqlite3_exec(p->conf.sql, "COMMIT", NULL, NULL, &err)) { |
| 2198 | 2291 | log_error_write(srv, __FILE__, __LINE__, "ss", "can't commit transaction:", err); |
| ... | ...@@ -2212,11 +2305,13 @@ | |
| 2212 | 2305 | xmlFreeDoc(xml); |
| 2213 | 2306 | } else { |
| 2214 | 2307 | con->http_status = 400; |
| 2308 | con->mode = DIRECT; | |
| 2215 | 2309 | return HANDLER_FINISHED; |
| 2216 | 2310 | } |
| 2217 | 2311 | } |
| 2218 | 2312 | #endif |
| 2219 | 2313 | con->http_status = 501; |
| 2314 | con->mode = DIRECT; | |
| 2220 | 2315 | return HANDLER_FINISHED; |
| 2221 | 2316 | case HTTP_METHOD_LOCK: |
| 2222 | 2317 | /** |
| ... | ...@@ -2244,12 +2339,13 @@ | |
| 2244 | 2339 | |
| 2245 | 2340 | if (depth != 0 && depth != -1) { |
| 2246 | 2341 | con->http_status = 400; |
| 2342 | con->mode = DIRECT; | |
| 2247 | 2343 | |
| 2248 | 2344 | return HANDLER_FINISHED; |
| 2249 | 2345 | } |
| 2250 | 2346 | |
| 2251 | 2347 | #ifdef USE_LOCKS |
| 2252 | if (con->request.content_length) { | |
| 2348 | if (p->conf.sql && con->request.content_length > 0) { | |
| 2253 | 2349 | xmlDocPtr xml; |
| 2254 | 2350 | buffer *hdr_if = NULL; |
| 2255 | 2351 | |
| ... | ...@@ -2260,6 +2356,7 @@ | |
| 2260 | 2356 | /* we don't support Depth: Infinity on locks */ |
| 2261 | 2357 | if (hdr_if == NULL && depth == -1) { |
| 2262 | 2358 | con->http_status = 409; /* Conflict */ |
| 2359 | con->mode = DIRECT; | |
| 2263 | 2360 | |
| 2264 | 2361 | return HANDLER_FINISHED; |
| 2265 | 2362 | } |
| ... | ...@@ -2282,6 +2379,7 @@ | |
| 2282 | 2379 | lockscope = value->name; |
| 2283 | 2380 | } else { |
| 2284 | 2381 | con->http_status = 400; |
| 2382 | con->mode = DIRECT; | |
| 2285 | 2383 | |
| 2286 | 2384 | xmlFreeDoc(xml); |
| 2287 | 2385 | return HANDLER_FINISHED; |
| ... | ...@@ -2294,6 +2392,7 @@ | |
| 2294 | 2392 | locktype = value->name; |
| 2295 | 2393 | } else { |
| 2296 | 2394 | con->http_status = 400; |
| 2395 | con->mode = DIRECT; | |
| 2297 | 2396 | |
| 2298 | 2397 | xmlFreeDoc(xml); |
| 2299 | 2398 | return HANDLER_FINISHED; |
| ... | ...@@ -2331,10 +2430,12 @@ | |
| 2331 | 2430 | |
| 2332 | 2431 | if (strcmp(sql_lockscope, "exclusive")) { |
| 2333 | 2432 | con->http_status = 423; |
| 2433 | con->mode = DIRECT; | |
| 2334 | 2434 | } else if (0 == xmlStrcmp(lockscope, BAD_CAST "exclusive")) { |
| 2335 | 2435 | /* resourse is locked with a shared lock |
| 2336 | 2436 | * client wants exclusive */ |
| 2337 | 2437 | con->http_status = 423; |
| 2438 | con->mode = DIRECT; | |
| 2338 | 2439 | } |
| 2339 | 2440 | } |
| 2340 | 2441 | if (con->http_status == 423) { |
| ... | ...@@ -2413,6 +2514,7 @@ | |
| 2413 | 2514 | return HANDLER_FINISHED; |
| 2414 | 2515 | } else { |
| 2415 | 2516 | con->http_status = 400; |
| 2517 | con->mode = DIRECT; | |
| 2416 | 2518 | return HANDLER_FINISHED; |
| 2417 | 2519 | } |
| 2418 | 2520 | } else { |
| ... | ...@@ -2424,6 +2526,7 @@ | |
| 2424 | 2526 | /* remove the < > around the token */ |
| 2425 | 2527 | if (locktoken->used < 6) { |
| 2426 | 2528 | con->http_status = 400; |
| 2529 | con->mode = DIRECT; | |
| 2427 | 2530 | |
| 2428 | 2531 | return HANDLER_FINISHED; |
| 2429 | 2532 | } |
| ... | ...@@ -2448,6 +2551,7 @@ | |
| 2448 | 2551 | } else { |
| 2449 | 2552 | /* we need a lock-token to refresh */ |
| 2450 | 2553 | con->http_status = 400; |
| 2554 | con->mode = DIRECT; | |
| 2451 | 2555 | |
| 2452 | 2556 | return HANDLER_FINISHED; |
| 2453 | 2557 | } |
| ... | ...@@ -2455,6 +2559,7 @@ | |
| 2455 | 2559 | break; |
| 2456 | 2560 | #else |
| 2457 | 2561 | con->http_status = 501; |
| 2562 | con->mode = DIRECT; | |
| 2458 | 2563 | return HANDLER_FINISHED; |
| 2459 | 2564 | #endif |
| 2460 | 2565 | case HTTP_METHOD_UNLOCK: |
| ... | ...@@ -2466,6 +2571,7 @@ | |
| 2466 | 2571 | /* remove the < > around the token */ |
| 2467 | 2572 | if (locktoken->used < 4) { |
| 2468 | 2573 | con->http_status = 400; |
| 2574 | con->mode = DIRECT; | |
| 2469 | 2575 | |
| 2470 | 2576 | return HANDLER_FINISHED; |
| 2471 | 2577 | } |
| ... | ...@@ -2499,19 +2605,23 @@ | |
| 2499 | 2605 | |
| 2500 | 2606 | if (0 == sqlite3_changes(p->conf.sql)) { |
| 2501 | 2607 | con->http_status = 401; |
| 2608 | con->mode = DIRECT; | |
| 2502 | 2609 | } else { |
| 2503 | 2610 | con->http_status = 204; |
| 2611 | con->send->is_closed = 1; | |
| 2504 | 2612 | } |
| 2505 | 2613 | return HANDLER_FINISHED; |
| 2506 | 2614 | } else { |
| 2507 | 2615 | /* we need a lock-token to unlock */ |
| 2508 | 2616 | con->http_status = 400; |
| 2617 | con->mode = DIRECT; | |
| 2509 | 2618 | |
| 2510 | 2619 | return HANDLER_FINISHED; |
| 2511 | 2620 | } |
| 2512 | 2621 | break; |
| 2513 | 2622 | #else |
| 2514 | 2623 | con->http_status = 501; |
| 2624 | con->mode = DIRECT; | |
| 2515 | 2625 | return HANDLER_FINISHED; |
| 2516 | 2626 | #endif |
| 2517 | 2627 | default: |
| ... | ...@@ -2528,17 +2638,24 @@ | |
| 2528 | 2638 | CONNECTION_FUNC(mod_webdav_recv_request_content) { |
| 2529 | 2639 | chunkqueue *in = con->recv; |
| 2530 | 2640 | plugin_data *p = p_d; |
| 2641 | handler_t res; | |
| 2531 | 2642 | |
| 2532 | 2643 | /** |
| 2533 | 2644 | * is the content for webdav |
| 2534 | 2645 | */ |
| 2535 | if (!p->conf.enabled) return HANDLER_GO_ON; | |
| 2646 | if (con->mode != p->id) return HANDLER_GO_ON; | |
| 2536 | 2647 | |
| 2537 | 2648 | if (!in->is_closed) return HANDLER_GO_ON; |
| 2538 | 2649 | |
| 2539 | 2650 | /* we received all the content, let's call the webdav handler */ |
| 2540 | 2651 | |
| 2541 | return mod_webdav_subrequest_handler(srv, con, p_d); | |
| 2652 | res = mod_webdav_subrequest_handler(srv, con, p_d); | |
| 2653 | ||
| 2654 | /* mark body as read */ | |
| 2655 | con->recv->bytes_out += chunkqueue_skip(con->recv, con->recv->bytes_in - con->recv->bytes_out); | |
| 2656 | chunkqueue_remove_finished_chunks(con->recv); | |
| 2657 | ||
| 2658 | return res; | |
| 2542 | 2659 | } |
| 2543 | 2660 | |
| 2544 | 2661 | /* this function is called at dlopen() time and inits the callbacks */ |
| ... | ...@@ -2551,8 +2668,8 @@ | |
| 2551 | 2668 | p->handle_uri_clean = mod_webdav_uri_handler; /* check if we handle this URL */ |
| 2552 | 2669 | #if 0 |
| 2553 | 2670 | /* will get called when the content is received */ |
| 2554 | p->handle_physical = mod_webdav_subrequest_handler; | |
| 2555 | 2671 | #endif |
| 2672 | p->handle_physical = mod_webdav_physical_handler; | |
| 2556 | 2673 | p->handle_send_request_content = mod_webdav_recv_request_content; /* check if we received all the content */ |
| 2557 | 2674 | p->set_defaults = mod_webdav_set_defaults; |
| 2558 | 2675 | p->cleanup = mod_webdav_free; |
| ... | ...@@ -50,6 +50,7 @@ | |
| 50 | 50 | * merged from @1874: add ETag configuration (#1442) |
| 51 | 51 | * case insensitive match for secdownload md5 token (#1710) |
| 52 | 52 | * handle only HEAD, GET and POST in mod_dirlisting (same as in staticfile) (#1687) |
| 53 | * fixed mod_webdav, litmus now passes everything except locks (#1738) | |
| 53 | 54 | |
| 54 | 55 | - 1.5.0-r19.. - |
| 55 | 56 | * -F option added for spawn-fcgi |