mholt / caddy-webdav

WebDAV handler module for Caddy
Apache License 2.0
228 stars 24 forks source link

Can not upload large file #30

Closed lyh458 closed 2 years ago

lyh458 commented 2 years ago

Hi,

Thanks for the awesome work. There is an issue trouble me when I use this module. Large file can not be upload to the webdav server even caddy and caddy-webdav start normally. However, small file can be uploaded and deleted, and large file can alse be deleted. And all is well if basicauth is not set, similar to the issue mentioned here. Here is my detailed info:

dav.mydomain.com { log { output file /var/log/caddy/caddy.log } header { Access-Control-Allow-Origin * Access-Control-Allow-Credentials true Access-Control-Allow-Methods "GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL" Access-Control-Allow-Headers "Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader" Access-Control-Expose-Headers "ETag" Access-Control-Max-Age 1728000 } file_server webdav { root /data/webdav } basicauth { username JDJhJDE0JGxYYWhxUVd6a1RRd01PS2xtNnBkNHUzUllqenFaSGFib1Zid1BFaGNRSmpOLktXNXBJbGhH } }


- log
*note*: the size of `file1` is 5 bytes, `file2` is 18.6 MB and `file3` is 18.6 MB.
```log
{"level":"error","ts":1649603015.3900425,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"my_ip:16834","proto":"HTTP/1.1","method":"PUT","host":"dav.mydomain","uri":"/zotero/file1","headers":{"Content-Type":["application/octet-stream"],"Content-Length":["5"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"dav.mydomain"}},"common_log":"my_ip - - [10/Apr/2022:15:03:35 +0000] \"PUT /zotero/file1 HTTP/1.1\" 401 0","user_id":"","duration":0.000256805,"size":0,"status":401,"resp_headers":{"Access-Control-Allow-Origin":["*"],"Access-Control-Expose-Headers":["ETag"],"Access-Control-Max-Age":["1728000"],"Access-Control-Allow-Credentials":["true"],"Www-Authenticate":["Basic realm=\"restricted\""],"Server":["Caddy"],"Access-Control-Allow-Headers":["Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader"],"Access-Control-Allow-Methods":["GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL"]}}
{"level":"info","ts":1649603017.5407305,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"my_ip:16834","proto":"HTTP/1.1","method":"PUT","host":"dav.mydomain","uri":"/zotero/file1","headers":{"Authorization":["Basic bHloNDU4OkxZSDEyMzQ1Njc5"],"Content-Type":["application/octet-stream"],"Content-Length":["5"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"dav.mydomain"}},"common_log":"my_ip - username [10/Apr/2022:15:03:37 +0000] \"PUT /zotero/file1 HTTP/1.1\" 201 7","user_id":"username","duration":1.982221712,"size":7,"status":201,"resp_headers":{"Access-Control-Allow-Methods":["GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL"],"Access-Control-Allow-Origin":["*"],"Access-Control-Expose-Headers":["ETag"],"Access-Control-Max-Age":["1728000"],"Etag":["\"16e4913458b93d2d5\""],"Server":["Caddy"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Allow-Headers":["Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader"]}}
{"level":"error","ts":1649603055.6700094,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"my_ip:16834","proto":"HTTP/1.1","method":"PUT","host":"dav.mydomain","uri":"/zotero/file3","headers":{"Content-Type":["application/octet-stream"],"Content-Length":["18633601"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"dav.mydomain"}},"common_log":"my_ip - - [10/Apr/2022:15:04:15 +0000] \"PUT /zotero/file3 HTTP/1.1\" 401 0","user_id":"","duration":0.000145973,"size":0,"status":401,"resp_headers":{"Www-Authenticate":["Basic realm=\"restricted\""],"Server":["Caddy"],"Access-Control-Expose-Headers":["ETag"],"Access-Control-Max-Age":["1728000"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Allow-Headers":["Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader"],"Access-Control-Allow-Methods":["GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL"],"Access-Control-Allow-Origin":["*"]}}
{"level":"error","ts":1649603058.8734984,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"my_ip:17028","proto":"HTTP/1.1","method":"PUT","host":"dav.mydomain","uri":"/zotero/file3","headers":{"Content-Type":["application/octet-stream"],"Content-Length":["18633601"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"dav.mydomain"}},"common_log":"my_ip - - [10/Apr/2022:15:04:18 +0000] \"PUT /zotero/file3 HTTP/1.1\" 401 0","user_id":"","duration":0.000120796,"size":0,"status":401,"resp_headers":{"Access-Control-Max-Age":["1728000"],"Access-Control-Allow-Credentials":["true"],"Www-Authenticate":["Basic realm=\"restricted\""],"Server":["Caddy"],"Access-Control-Allow-Headers":["Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader"],"Access-Control-Allow-Methods":["GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL"],"Access-Control-Allow-Origin":["*"],"Access-Control-Expose-Headers":["ETag"]}}
{"level":"error","ts":1649603061.5329177,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"my_ip:17056","proto":"HTTP/1.1","method":"PUT","host":"dav.mydomain","uri":"/zotero/file3","headers":{"Content-Type":["application/octet-stream"],"Content-Length":["18633601"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"dav.mydomain"}},"common_log":"my_ip - - [10/Apr/2022:15:04:21 +0000] \"PUT /zotero/file3 HTTP/1.1\" 401 0","user_id":"","duration":0.000104573,"size":0,"status":401,"resp_headers":{"Access-Control-Allow-Origin":["*"],"Access-Control-Expose-Headers":["ETag"],"Access-Control-Max-Age":["1728000"],"Www-Authenticate":["Basic realm=\"restricted\""],"Server":["Caddy"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Allow-Headers":["Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader"],"Access-Control-Allow-Methods":["GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL"]}}
{"level":"error","ts":1649603064.0896423,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"my_ip:17080","proto":"HTTP/1.1","method":"PUT","host":"dav.mydomain","uri":"/zotero/file3","headers":{"Content-Length":["18633601"],"Content-Type":["application/octet-stream"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"dav.mydomain"}},"common_log":"my_ip - - [10/Apr/2022:15:04:24 +0000] \"PUT /zotero/file3 HTTP/1.1\" 401 0","user_id":"","duration":0.000129379,"size":0,"status":401,"resp_headers":{"Access-Control-Allow-Origin":["*"],"Access-Control-Expose-Headers":["ETag"],"Access-Control-Max-Age":["1728000"],"Www-Authenticate":["Basic realm=\"restricted\""],"Server":["Caddy"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Allow-Headers":["Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader"],"Access-Control-Allow-Methods":["GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL"]}}
{"level":"error","ts":1649603067.0620177,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"my_ip:17116","proto":"HTTP/1.1","method":"PROPFIND","host":"dav.mydomain","uri":"/zotero/","headers":{"Depth":["1"],"Traceparent":["00-95bcf341ff0e0f898331c275b059a2aa-d1700fca3284ce5e-00"],"Content-Type":["application/xml; charset=utf-8"],"Content-Length":["96"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"dav.mydomain"}},"common_log":"my_ip - - [10/Apr/2022:15:04:27 +0000] \"PROPFIND /zotero/ HTTP/1.1\" 401 0","user_id":"","duration":0.000231393,"size":0,"status":401,"resp_headers":{"Access-Control-Max-Age":["1728000"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Allow-Headers":["Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader"],"Www-Authenticate":["Basic realm=\"restricted\""],"Server":["Caddy"],"Access-Control-Allow-Methods":["GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL"],"Access-Control-Allow-Origin":["*"],"Access-Control-Expose-Headers":["ETag"]}}
{"level":"info","ts":1649603067.272328,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"my_ip:17116","proto":"HTTP/1.1","method":"PROPFIND","host":"dav.mydomain","uri":"/zotero/","headers":{"Depth":["1"],"Traceparent":["00-95bcf341ff0e0f898331c275b059a2aa-d1700fca3284ce5e-00"],"Authorization":["Basic bHloNDU4OkxZSDEyMzQ1Njc5"],"Content-Type":["application/xml; charset=utf-8"],"Content-Length":["96"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"dav.mydomain"}},"common_log":"my_ip - username [10/Apr/2022:15:04:27 +0000] \"PROPFIND /zotero/ HTTP/1.1\" 207 1674","user_id":"username","duration":0.008953879,"size":1674,"status":207,"resp_headers":{"Access-Control-Allow-Origin":["*"],"Access-Control-Expose-Headers":["ETag"],"Access-Control-Max-Age":["1728000"],"Content-Type":["text/xml; charset=utf-8"],"Server":["Caddy"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Allow-Headers":["Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader"],"Access-Control-Allow-Methods":["GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL"]}}
{"level":"error","ts":1649603067.4928412,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"my_ip:17116","proto":"HTTP/1.1","method":"PROPFIND","host":"dav.mydomain","uri":"/","headers":{"Depth":["1"],"Traceparent":["00-95bcf341ff0e0f898331c275b059a2aa-cde040a9d5b79e46-00"],"Content-Type":["application/xml; charset=utf-8"],"Content-Length":["96"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"dav.mydomain"}},"common_log":"my_ip - - [10/Apr/2022:15:04:27 +0000] \"PROPFIND / HTTP/1.1\" 401 0","user_id":"","duration":0.000132876,"size":0,"status":401,"resp_headers":{"Access-Control-Allow-Headers":["Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader"],"Access-Control-Allow-Methods":["GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL"],"Access-Control-Allow-Origin":["*"],"Access-Control-Expose-Headers":["ETag"],"Www-Authenticate":["Basic realm=\"restricted\""],"Server":["Caddy"],"Access-Control-Max-Age":["1728000"],"Access-Control-Allow-Credentials":["true"]}}
{"level":"info","ts":1649603067.6733172,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"my_ip:17116","proto":"HTTP/1.1","method":"PROPFIND","host":"dav.mydomain","uri":"/","headers":{"Traceparent":["00-95bcf341ff0e0f898331c275b059a2aa-cde040a9d5b79e46-00"],"Authorization":["Basic bHloNDU4OkxZSDEyMzQ1Njc5"],"Content-Type":["application/xml; charset=utf-8"],"Content-Length":["96"],"Depth":["1"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"dav.mydomain"}},"common_log":"my_ip - username [10/Apr/2022:15:04:27 +0000] \"PROPFIND / HTTP/1.1\" 207 969","user_id":"username","duration":0.000882937,"size":969,"status":207,"resp_headers":{"Content-Type":["text/xml; charset=utf-8"],"Server":["Caddy"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Allow-Headers":["Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite,X-CustomHeader"],"Access-Control-Allow-Methods":["GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK, PROPFIND, MKCOL"],"Access-Control-Allow-Origin":["*"],"Access-Control-Expose-Headers":["ETag"],"Access-Control-Max-Age":["1728000"]}}

Thanks in advance.

mholt commented 2 years ago

It seems that the requests logged with an error don't have the Authorization header set, which would be necessary to pass basicauth. Maybe a problem in the client?

(I only glanced at this quickly, apologies if I am missing something obvious. I also don't actually know too much about webdav, I just wrapped an underlying library.)

lyh458 commented 2 years ago

It seems that the requests logged with an error don't have the Authorization header set, which would be necessary to pass basicauth. Maybe a problem in the client?

(I only glanced at this quickly, apologies if I am missing something obvious. I also don't actually know too much about webdav, I just wrapped an underlying library.)

@mholt thanks the reply. Maybe you are right, I have tried to use other webdav clients to upload files to my server after seeing your reply, some worked, some did't.

I will close the issue and report the issue to the client's author.