<!-- review: finished -->

<a id="external-dav-ext"></a>

# DAV-Ext

此模块通过 PROPFIND、OPTIONS、LOCK 和 UNLOCK 方法扩展了 WebDAV 支持。

标准 [DAV](https://cn.angie.software//angie/docs/configuration/modules/http/http_dav.md#http-dav) 模块提供了 WebDAV 的部分实现,
仅支持 GET、HEAD、PUT、DELETE、MKCOL、COPY 和 MOVE 方法。
要获得完整的 WebDAV 支持,您需要启用标准的
`http_dav_module` 模块,以及此模块来支持缺失的方法。

<a id="installation-7"></a>

## 安装

要 [安装](https://cn.angie.software//angie/docs/installation/index.md#install-packages) 该模块,请使用以下软件包之一:

- Angie:`angie-module-dav-ext`
- Angie PRO:`angie-pro-module-dav-ext`

<a id="loading-the-module-6"></a>

## 加载模块

在 `main{}` 上下文中加载模块:

```nginx
load_module modules/ngx_http_dav_ext_module.so;
```

<a id="configuration-example-83"></a>

## 配置示例

```nginx
dav_ext_lock_zone zone=lock_zone:10m;
server {
    listen 80 default_server;

    location / {
        root /usr/share/angie/html;

        dav_methods PUT DELETE MKCOL COPY MOVE;
        dav_ext_methods PROPFIND OPTIONS LOCK UNLOCK;
        dav_ext_lock zone=lock_zone;
    }
}
```

<a id="request-execution-examples"></a>

## 请求执行示例

将文件上传到服务器:

```console
$ curl -i -X PUT -d @testf1.txt http://127.0.0.1/testf1.txt
HTTP/1.1 201 Created
Server: Angie/|angie_version|
Date: |sampledatelong| 19:15:35 GMT
Content-Length: 0
Location: http://127.0.0.1/testf1.txt
Connection: keep-alive
```

覆盖同一文件:

```console
$ curl -i -X PUT -d @testf1.txt http://127.0.0.1/testf1.txt
HTTP/1.1 204 No Content
Server: Angie/|angie_version|
Date: |sampledatelong| 19:15:35 GMT
Connection: keep-alive
```

锁定文件防止被覆盖:

```console
$ curl -i -X LOCK http://127.0.0.1/testf1.txt
HTTP/1.1 200 OK
Server: Angie/|angie_version|
Date: |sampledatelong| 19:15:35 GMT
Content-Type: text/xml; charset=utf-8
Content-Length: 392
Connection: keep-alive
Lock-Token: <urn:7502d56f>
```

尝试覆盖文件:

```console
$ curl -i -X PUT -d @testf1.txt http://127.0.0.1/testf1.txt
HTTP/1.1 423
Server: Angie/|angie_version|
Date: |sampledatelong| 19:15:35 GMT
Content-Length: 0
Connection: keep-alive
```

文件已被锁定。解锁文件:

```console
$ curl -i -X UNLOCK -H 'Lock-Token: <urn:7502d56f>' http://127.0.0.1/testf1.txt
HTTP/1.1 204 No Content
Server: Angie/|angie_version|
Date: |sampledatelong| 19:15:35 GMT
Connection: keep-alive
```

覆盖文件:

```console
$ curl -i -X PUT -d @testf1.txt http://127.0.0.1/testf1.txt
HTTP/1.1 204 No Content
Server: Angie/|angie_version|
Date: |sampledatelong| 19:15:35 GMT
Connection: keep-alive
```

文件已成功解锁并覆盖。

<a id="additional-information-7"></a>

## 附加信息

详细文档和源代码可在以下位置获取:
[https://github.com/arut/nginx-dav-ext-module](https://github.com/arut/nginx-dav-ext-module)
