Sun, 15 Sep 2024 09:47:36 +0200
improve sessionhandler trace logging
13 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
4 | * Copyright 2019 Olaf Wintermann. All rights reserved. |
13 | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
29 | #ifndef WEBDAV_H | |
30 | #define WEBDAV_H | |
31 | ||
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
32 | #include "../public/webdav.h" |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
33 | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
34 | #include <cx/map.h> |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
35 | #include <cx/list.h> |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
36 | #include <cx/buffer.h> |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
37 | #include <cx/string.h> |
13 | 38 | |
39 | #ifdef __cplusplus | |
40 | extern "C" { | |
41 | #endif | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
213
diff
changeset
|
42 | |
366
47bc686fafe4
add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
43 | typedef struct WebdavType { |
47bc686fafe4
add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
44 | webdav_init_func init; |
47bc686fafe4
add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
45 | webdav_create_func create; |
47bc686fafe4
add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
46 | } WebdavType; |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
47 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
48 | typedef struct DefaultWebdavData { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
49 | WebdavVFSProperties vfsproperties; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
50 | } DefaultWebdavData; |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
51 | |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
52 | typedef struct WebdavPropfindRequestList WebdavPropfindRequestList; |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
53 | struct WebdavPropfindRequestList { |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
54 | WebdavPropfindRequest *propfind; |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
55 | WebdavPropfindRequestList *next; |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
56 | }; |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
57 | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
58 | WebdavType* webdav_get_type(cxstring dav_class); |
366
47bc686fafe4
add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
59 | |
47bc686fafe4
add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
60 | void* webdav_init_backend(ServerConfiguration *cfg, pool_handle_t *pool, WebdavType *dav_class, WSConfigNode *config, int *error); |
47bc686fafe4
add new dav config element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
61 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
62 | int webdav_init(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
63 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
64 | int webdav_service(pblock *pb, Session *sn, Request *rq); |
30
27c7511c0e34
new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
65 | |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
66 | /* |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
67 | * returns a buffer containing the request body |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
68 | * |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
69 | * this function sets an http response code in case of an error |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
70 | * or missing request body |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
71 | */ |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
72 | int rqbody2buffer(Session *sn, Request *rq, CxBuffer *buf); |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
73 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
74 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
75 | int webdav_options(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
76 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
77 | int webdav_propfind(pblock *pb, Session *sn, Request *rq); |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
78 | |
213
4a6be4f10d5f
move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
79 | int webdav_propfind_init( |
4a6be4f10d5f
move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
80 | WebdavBackend *dav, |
4a6be4f10d5f
move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
81 | WebdavPropfindRequest *propfind, |
4a6be4f10d5f
move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
82 | const char *path, |
307
8787cb5ebab3
fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
252
diff
changeset
|
83 | const char *uri, |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
84 | WebdavPropfindRequestList **out_req); |
213
4a6be4f10d5f
move backend initialization to new function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
85 | |
252
5653a9626cc0
prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
86 | int webdav_propfind_do( |
5653a9626cc0
prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
87 | WebdavBackend *dav, |
5653a9626cc0
prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
88 | WebdavPropfindRequest *propfind, |
5653a9626cc0
prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
89 | WebdavResponse *response, |
5653a9626cc0
prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
90 | VFSContext *vfs, |
5653a9626cc0
prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
91 | char *path, |
5653a9626cc0
prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
92 | char *uri); |
5653a9626cc0
prepare webdav copy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
93 | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
213
diff
changeset
|
94 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
95 | int webdav_proppatch(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
96 | int webdav_mkcol(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
97 | int webdav_post(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
98 | int webdav_delete(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
99 | int webdav_put(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
100 | int webdav_copy(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
101 | int webdav_move(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
102 | int webdav_lock(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
103 | int webdav_unlock(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
104 | int webdav_report(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
105 | int webdav_acl(pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
106 | int webdav_search (pblock *pb, Session *sn, Request *rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
107 | |
244
e59abb210584
add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
243
diff
changeset
|
108 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
109 | int default_propfind_init( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
110 | WebdavPropfindRequest *rq, |
307
8787cb5ebab3
fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
252
diff
changeset
|
111 | const char *path, |
8787cb5ebab3
fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
252
diff
changeset
|
112 | const char *href, |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
113 | WebdavPList **outplist); |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
114 | int default_propfind_do( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
115 | WebdavPropfindRequest *request, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
116 | WebdavResponse *response, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
117 | VFS_DIR parent, |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
213
diff
changeset
|
118 | WebdavResource *resource, |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
119 | struct stat *s); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
107
diff
changeset
|
120 | int default_propfind_finish(WebdavPropfindRequest *rq); |
243
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
121 | int default_proppatch_do( |
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
122 | WebdavProppatchRequest *request, |
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
123 | WebdavResource *response, |
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
124 | VFSFile *file, |
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
125 | WebdavPList **setInOut, |
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
126 | WebdavPList **removeInOut); |
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
127 | int default_proppatch_finish( |
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
128 | WebdavProppatchRequest *request, |
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
129 | WebdavResource *response, |
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
130 | VFSFile *file, |
1a29b1d8d9d8
add proppatch handler to default backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
131 | WSBool commit); |
13 | 132 | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
133 | CxHashKey webdav_property_key(const char *ns, const char *name); |
373
f78a585e1a2f
add parser for extended postgresql webdav config
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
366
diff
changeset
|
134 | |
490 | 135 | CxHashKey webdav_property_key_a(const CxAllocator *a, const char *ns, const char *name); |
481
31affbf33911
implement proppatch of the xattr webdav backend
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
136 | |
13 | 137 | #ifdef __cplusplus |
138 | } | |
139 | #endif | |
140 | ||
141 | #endif /* WEBDAV_H */ | |
142 |