Mercurial > hg > nginx
annotate src/http/modules/ngx_http_dav_module.c @ 1825:2e0fbfef56d4
do not delete target until all tests will be done,
fix single file COPY/MOVE
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 03 Jan 2008 21:44:38 +0000 |
parents | 8299cd253745 |
children | 1f3c2b6607e0 |
rev | line source |
---|---|
633 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 #include <ngx_http.h> | |
10 | |
11 | |
1116 | 12 #define NGX_HTTP_DAV_COPY_BLOCK 65536 |
13 | |
14 #define NGX_HTTP_DAV_OFF 2 | |
15 | |
16 | |
17 #define NGX_HTTP_DAV_NO_DEPTH -3 | |
18 #define NGX_HTTP_DAV_INVALID_DEPTH -2 | |
19 #define NGX_HTTP_DAV_INFINITY_DEPTH -1 | |
20 | |
633 | 21 |
22 typedef struct { | |
23 ngx_uint_t methods; | |
1816 | 24 ngx_uint_t access; |
25 ngx_uint_t min_delete_depth; | |
637 | 26 ngx_flag_t create_full_put_path; |
633 | 27 } ngx_http_dav_loc_conf_t; |
28 | |
29 | |
1116 | 30 typedef struct { |
31 ngx_str_t path; | |
32 size_t len; | |
33 } ngx_http_dav_copy_ctx_t; | |
34 | |
35 | |
633 | 36 static ngx_int_t ngx_http_dav_handler(ngx_http_request_t *r); |
1116 | 37 |
38 static void ngx_http_dav_put_handler(ngx_http_request_t *r); | |
39 | |
40 static ngx_int_t ngx_http_dav_delete_handler(ngx_http_request_t *r); | |
1820 | 41 static ngx_int_t ngx_http_dav_delete_path(ngx_http_request_t *r, |
42 ngx_str_t *path, ngx_uint_t dir); | |
957 | 43 static ngx_int_t ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path); |
44 static ngx_int_t ngx_http_dav_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path); | |
1820 | 45 static ngx_int_t ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path); |
1116 | 46 |
47 static ngx_int_t ngx_http_dav_mkcol_handler(ngx_http_request_t *r, | |
48 ngx_http_dav_loc_conf_t *dlcf); | |
49 | |
50 static ngx_int_t ngx_http_dav_copy_move_handler(ngx_http_request_t *r); | |
51 static ngx_int_t ngx_http_dav_copy_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path); | |
52 static ngx_int_t ngx_http_dav_copy_dir_time(ngx_tree_ctx_t *ctx, | |
53 ngx_str_t *path); | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
54 static ngx_int_t ngx_http_dav_copy_tree_file(ngx_tree_ctx_t *ctx, |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
55 ngx_str_t *path); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
56 static ngx_int_t ngx_http_dav_copy_file(ngx_tree_ctx_t *ctx, u_char *from, |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
57 u_char *to); |
1116 | 58 |
59 static ngx_int_t ngx_http_dav_depth(ngx_http_request_t *r, ngx_int_t dflt); | |
60 static ngx_int_t ngx_http_dav_error(ngx_log_t *log, ngx_err_t err, | |
637 | 61 ngx_int_t not_found, char *failed, u_char *path); |
62 static ngx_int_t ngx_http_dav_location(ngx_http_request_t *r, u_char *path); | |
633 | 63 static void *ngx_http_dav_create_loc_conf(ngx_conf_t *cf); |
64 static char *ngx_http_dav_merge_loc_conf(ngx_conf_t *cf, | |
65 void *parent, void *child); | |
681 | 66 static ngx_int_t ngx_http_dav_init(ngx_conf_t *cf); |
633 | 67 |
68 | |
69 static ngx_conf_bitmask_t ngx_http_dav_methods_mask[] = { | |
70 { ngx_string("off"), NGX_HTTP_DAV_OFF }, | |
71 { ngx_string("put"), NGX_HTTP_PUT }, | |
72 { ngx_string("delete"), NGX_HTTP_DELETE }, | |
637 | 73 { ngx_string("mkcol"), NGX_HTTP_MKCOL }, |
1116 | 74 { ngx_string("copy"), NGX_HTTP_COPY }, |
75 { ngx_string("move"), NGX_HTTP_MOVE }, | |
633 | 76 { ngx_null_string, 0 } |
77 }; | |
78 | |
79 | |
80 static ngx_command_t ngx_http_dav_commands[] = { | |
81 | |
82 { ngx_string("dav_methods"), | |
83 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
84 ngx_conf_set_bitmask_slot, | |
85 NGX_HTTP_LOC_CONF_OFFSET, | |
86 offsetof(ngx_http_dav_loc_conf_t, methods), | |
87 &ngx_http_dav_methods_mask }, | |
88 | |
637 | 89 { ngx_string("create_full_put_path"), |
90 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
91 ngx_conf_set_flag_slot, | |
92 NGX_HTTP_LOC_CONF_OFFSET, | |
93 offsetof(ngx_http_dav_loc_conf_t, create_full_put_path), | |
94 NULL }, | |
95 | |
1816 | 96 { ngx_string("min_delete_depth"), |
97 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
98 ngx_conf_set_num_slot, | |
99 NGX_HTTP_LOC_CONF_OFFSET, | |
100 offsetof(ngx_http_dav_loc_conf_t, min_delete_depth), | |
101 NULL }, | |
102 | |
669 | 103 { ngx_string("dav_access"), |
675 | 104 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, |
1296
9fcfca54b208
dav_access uses ngx_conf_set_access_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
1289
diff
changeset
|
105 ngx_conf_set_access_slot, |
669 | 106 NGX_HTTP_LOC_CONF_OFFSET, |
1296
9fcfca54b208
dav_access uses ngx_conf_set_access_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
1289
diff
changeset
|
107 offsetof(ngx_http_dav_loc_conf_t, access), |
669 | 108 NULL }, |
109 | |
633 | 110 ngx_null_command |
111 }; | |
112 | |
113 | |
667 | 114 static ngx_http_module_t ngx_http_dav_module_ctx = { |
633 | 115 NULL, /* preconfiguration */ |
681 | 116 ngx_http_dav_init, /* postconfiguration */ |
633 | 117 |
118 NULL, /* create main configuration */ | |
119 NULL, /* init main configuration */ | |
120 | |
121 NULL, /* create server configuration */ | |
122 NULL, /* merge server configuration */ | |
123 | |
124 ngx_http_dav_create_loc_conf, /* create location configuration */ | |
125 ngx_http_dav_merge_loc_conf /* merge location configuration */ | |
126 }; | |
127 | |
128 | |
129 ngx_module_t ngx_http_dav_module = { | |
130 NGX_MODULE_V1, | |
131 &ngx_http_dav_module_ctx, /* module context */ | |
132 ngx_http_dav_commands, /* module directives */ | |
133 NGX_HTTP_MODULE, /* module type */ | |
134 NULL, /* init master */ | |
681 | 135 NULL, /* init module */ |
633 | 136 NULL, /* init process */ |
137 NULL, /* init thread */ | |
138 NULL, /* exit thread */ | |
139 NULL, /* exit process */ | |
140 NULL, /* exit master */ | |
141 NGX_MODULE_V1_PADDING | |
142 }; | |
143 | |
144 | |
145 static ngx_int_t | |
146 ngx_http_dav_handler(ngx_http_request_t *r) | |
147 { | |
148 ngx_int_t rc; | |
149 ngx_http_dav_loc_conf_t *dlcf; | |
150 | |
151 /* TODO: Win32 */ | |
152 if (r->zero_in_uri) { | |
153 return NGX_DECLINED; | |
154 } | |
155 | |
156 dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module); | |
157 | |
158 if (!(r->method & dlcf->methods)) { | |
159 return NGX_DECLINED; | |
160 } | |
161 | |
162 switch (r->method) { | |
163 | |
164 case NGX_HTTP_PUT: | |
165 | |
166 if (r->uri.data[r->uri.len - 1] == '/') { | |
1813
d3f80e0be8fa
change status code and add log message
Igor Sysoev <igor@sysoev.ru>
parents:
1804
diff
changeset
|
167 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
d3f80e0be8fa
change status code and add log message
Igor Sysoev <igor@sysoev.ru>
parents:
1804
diff
changeset
|
168 "can not PUT to a collection"); |
d3f80e0be8fa
change status code and add log message
Igor Sysoev <igor@sysoev.ru>
parents:
1804
diff
changeset
|
169 return NGX_HTTP_CONFLICT; |
633 | 170 } |
171 | |
172 r->request_body_in_file_only = 1; | |
173 r->request_body_in_persistent_file = 1; | |
1075
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
1060
diff
changeset
|
174 r->request_body_in_clean_file = 1; |
633 | 175 r->request_body_file_group_access = 1; |
637 | 176 r->request_body_file_log_level = 0; |
633 | 177 |
178 rc = ngx_http_read_client_request_body(r, ngx_http_dav_put_handler); | |
179 | |
180 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
181 return rc; | |
182 } | |
183 | |
184 return NGX_DONE; | |
185 | |
186 case NGX_HTTP_DELETE: | |
187 | |
1116 | 188 return ngx_http_dav_delete_handler(r); |
637 | 189 |
190 case NGX_HTTP_MKCOL: | |
191 | |
1116 | 192 return ngx_http_dav_mkcol_handler(r, dlcf); |
637 | 193 |
1116 | 194 case NGX_HTTP_COPY: |
637 | 195 |
1116 | 196 return ngx_http_dav_copy_move_handler(r); |
637 | 197 |
1116 | 198 case NGX_HTTP_MOVE: |
637 | 199 |
1116 | 200 return ngx_http_dav_copy_move_handler(r); |
633 | 201 } |
202 | |
203 return NGX_DECLINED; | |
204 } | |
205 | |
206 | |
207 static void | |
208 ngx_http_dav_put_handler(ngx_http_request_t *r) | |
209 { | |
669 | 210 char *failed; |
211 u_char *name; | |
773 | 212 size_t root; |
681 | 213 time_t date; |
637 | 214 ngx_err_t err; |
215 ngx_str_t *temp, path; | |
1116 | 216 ngx_uint_t status, not_found; |
637 | 217 ngx_file_info_t fi; |
218 ngx_http_dav_loc_conf_t *dlcf; | |
633 | 219 |
773 | 220 ngx_http_map_uri_to_path(r, &path, &root, 0); |
633 | 221 |
222 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
223 "http put filename: \"%s\"", path.data); | |
224 | |
225 temp = &r->request_body->temp_file->file.name; | |
226 | |
227 if (ngx_file_info(path.data, &fi) == -1) { | |
228 status = NGX_HTTP_CREATED; | |
229 | |
230 } else { | |
231 status = NGX_HTTP_NO_CONTENT; | |
663 | 232 |
233 if (ngx_is_dir(&fi)) { | |
234 ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_EISDIR, | |
235 "\"%s\" could not be created", path.data); | |
633 | 236 |
663 | 237 if (ngx_delete_file(temp->data) == NGX_FILE_ERROR) { |
238 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, | |
239 ngx_delete_file_n " \"%s\" failed", | |
240 temp->data); | |
241 } | |
242 | |
243 ngx_http_finalize_request(r, NGX_HTTP_CONFLICT); | |
244 return; | |
661 | 245 } |
637 | 246 } |
247 | |
669 | 248 dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module); |
249 | |
250 #if !(NGX_WIN32) | |
251 | |
1289 | 252 if (ngx_change_file_access(temp->data, dlcf->access) == NGX_FILE_ERROR) { |
669 | 253 err = ngx_errno; |
1116 | 254 not_found = NGX_HTTP_INTERNAL_SERVER_ERROR; |
669 | 255 failed = ngx_change_file_access_n; |
256 name = temp->data; | |
257 | |
258 goto failed; | |
259 } | |
260 | |
261 #endif | |
262 | |
681 | 263 if (r->headers_in.date) { |
264 date = ngx_http_parse_time(r->headers_in.date->value.data, | |
265 r->headers_in.date->value.len); | |
266 | |
267 if (date != NGX_ERROR) { | |
268 if (ngx_set_file_time(temp->data, | |
269 r->request_body->temp_file->file.fd, date) | |
270 != NGX_OK) | |
271 { | |
272 err = ngx_errno; | |
1116 | 273 not_found = NGX_HTTP_INTERNAL_SERVER_ERROR; |
681 | 274 failed = ngx_set_file_time_n; |
275 name = temp->data; | |
276 | |
277 goto failed; | |
278 } | |
279 } | |
280 } | |
281 | |
1116 | 282 not_found = NGX_HTTP_CONFLICT; |
669 | 283 failed = ngx_rename_file_n; |
284 name = path.data; | |
285 | |
633 | 286 if (ngx_rename_file(temp->data, path.data) != NGX_FILE_ERROR) { |
287 goto ok; | |
288 } | |
289 | |
290 err = ngx_errno; | |
291 | |
637 | 292 if (err == NGX_ENOENT) { |
293 | |
294 if (dlcf->create_full_put_path) { | |
1089
b2e6eb425770
use ngx_dir_access() to enable search bits for directory
Igor Sysoev <igor@sysoev.ru>
parents:
1075
diff
changeset
|
295 err = ngx_create_full_path(path.data, ngx_dir_access(dlcf->access)); |
637 | 296 |
297 if (err == 0) { | |
298 if (ngx_rename_file(temp->data, path.data) != NGX_FILE_ERROR) { | |
299 goto ok; | |
300 } | |
301 | |
302 err = ngx_errno; | |
303 } | |
304 } | |
305 } | |
306 | |
633 | 307 #if (NGX_WIN32) |
308 | |
309 if (err == NGX_EEXIST) { | |
1693
f4eb04fd8579
use malloc() in ngx_win32_rename_file, set crit level instead of error
Igor Sysoev <igor@sysoev.ru>
parents:
1374
diff
changeset
|
310 if (ngx_win32_rename_file(temp, &path, r->connection->log) == NGX_OK) { |
633 | 311 |
312 if (ngx_rename_file(temp->data, path.data) != NGX_FILE_ERROR) { | |
313 goto ok; | |
314 } | |
315 } | |
316 | |
317 err = ngx_errno; | |
318 } | |
319 | |
681 | 320 #endif |
669 | 321 |
322 failed: | |
323 | |
661 | 324 if (ngx_delete_file(temp->data) == NGX_FILE_ERROR) { |
325 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, | |
326 ngx_delete_file_n " \"%s\" failed", | |
327 temp->data); | |
328 } | |
329 | |
669 | 330 ngx_http_finalize_request(r, |
1116 | 331 ngx_http_dav_error(r->connection->log, err, |
332 not_found, failed, name)); | |
669 | 333 |
633 | 334 return; |
335 | |
336 ok: | |
337 | |
338 if (status == NGX_HTTP_CREATED) { | |
637 | 339 if (ngx_http_dav_location(r, path.data) != NGX_OK) { |
633 | 340 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
341 return; | |
342 } | |
639 | 343 |
344 r->headers_out.content_length_n = 0; | |
633 | 345 } |
346 | |
347 r->headers_out.status = status; | |
348 r->header_only = 1; | |
349 | |
350 ngx_http_finalize_request(r, ngx_http_send_header(r)); | |
351 return; | |
352 } | |
353 | |
354 | |
637 | 355 static ngx_int_t |
1116 | 356 ngx_http_dav_delete_handler(ngx_http_request_t *r) |
357 { | |
1816 | 358 size_t root; |
359 ngx_err_t err; | |
360 ngx_int_t rc, depth; | |
361 ngx_uint_t i, d, dir; | |
362 ngx_str_t path; | |
363 ngx_file_info_t fi; | |
364 ngx_http_dav_loc_conf_t *dlcf; | |
1116 | 365 |
366 if (r->headers_in.content_length_n > 0) { | |
1815 | 367 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
368 "DELETE with body is unsupported"); | |
1116 | 369 return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE; |
370 } | |
371 | |
1816 | 372 dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module); |
373 | |
374 if (dlcf->min_delete_depth) { | |
375 d = 0; | |
376 | |
377 for (i = 0; i < r->uri.len; /* void */) { | |
378 if (r->uri.data[i++] == '/') { | |
379 if (++d >= dlcf->min_delete_depth && i < r->uri.len) { | |
380 goto ok; | |
381 } | |
382 } | |
383 } | |
384 | |
385 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
386 "insufficient URI depth:%i to DELETE", d); | |
387 return NGX_HTTP_CONFLICT; | |
388 } | |
389 | |
390 ok: | |
391 | |
1116 | 392 ngx_http_map_uri_to_path(r, &path, &root, 0); |
393 | |
394 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
395 "http delete filename: \"%s\"", path.data); | |
396 | |
397 if (ngx_file_info(path.data, &fi) == -1) { | |
1815 | 398 err = ngx_errno; |
399 | |
400 rc = (err == NGX_ENOTDIR) ? NGX_HTTP_CONFLICT : NGX_HTTP_NOT_FOUND; | |
401 | |
402 return ngx_http_dav_error(r->connection->log, err, | |
403 rc, ngx_file_info_n, path.data); | |
1116 | 404 } |
405 | |
406 if (ngx_is_dir(&fi)) { | |
407 | |
408 if (r->uri.data[r->uri.len - 1] != '/') { | |
1815 | 409 ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_EISDIR, |
410 "DELETE \"%s\" failed", path.data); | |
411 return NGX_HTTP_CONFLICT; | |
1116 | 412 } |
413 | |
414 depth = ngx_http_dav_depth(r, NGX_HTTP_DAV_INFINITY_DEPTH); | |
415 | |
416 if (depth != NGX_HTTP_DAV_INFINITY_DEPTH) { | |
1815 | 417 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
418 "\"Depth\" header must be infinity"); | |
1116 | 419 return NGX_HTTP_BAD_REQUEST; |
420 } | |
421 | |
422 path.len -= 2; /* omit "/\0" */ | |
423 | |
424 dir = 1; | |
425 | |
426 } else { | |
427 | |
1823 | 428 /* |
429 * we do not need to test (r->uri.data[r->uri.len - 1] == '/') | |
430 * because it ngx_file_info("/file/") returned NGX_ENOTDIR above | |
431 */ | |
432 | |
1116 | 433 depth = ngx_http_dav_depth(r, 0); |
434 | |
435 if (depth != 0 && depth != NGX_HTTP_DAV_INFINITY_DEPTH) { | |
1815 | 436 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
437 "\"Depth\" header must be 0 or infinity"); | |
1116 | 438 return NGX_HTTP_BAD_REQUEST; |
439 } | |
440 | |
441 dir = 0; | |
442 } | |
443 | |
444 rc = ngx_http_dav_delete_path(r, &path, dir); | |
445 | |
446 if (rc == NGX_OK) { | |
447 return NGX_HTTP_NO_CONTENT; | |
448 } | |
449 | |
450 return rc; | |
451 } | |
452 | |
453 | |
454 static ngx_int_t | |
1820 | 455 ngx_http_dav_delete_path(ngx_http_request_t *r, ngx_str_t *path, ngx_uint_t dir) |
1116 | 456 { |
1820 | 457 char *failed; |
458 ngx_tree_ctx_t tree; | |
459 | |
460 if (dir) { | |
461 | |
462 tree.init_handler = NULL; | |
463 tree.file_handler = ngx_http_dav_delete_file; | |
464 tree.pre_tree_handler = ngx_http_dav_noop; | |
465 tree.post_tree_handler = ngx_http_dav_delete_dir; | |
466 tree.spec_handler = ngx_http_dav_delete_file; | |
467 tree.data = NULL; | |
468 tree.alloc = 0; | |
469 tree.log = r->connection->log; | |
470 | |
471 /* TODO: 207 */ | |
472 | |
473 if (ngx_walk_tree(&tree, path) != NGX_OK) { | |
474 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
475 } | |
476 | |
477 if (ngx_delete_dir(path->data) != NGX_FILE_ERROR) { | |
478 return NGX_OK; | |
479 } | |
480 | |
481 failed = ngx_delete_dir_n; | |
482 | |
483 } else { | |
484 | |
485 if (ngx_delete_file(path->data) != NGX_FILE_ERROR) { | |
486 return NGX_OK; | |
487 } | |
488 | |
489 failed = ngx_delete_file_n; | |
490 } | |
491 | |
492 return ngx_http_dav_error(r->connection->log, ngx_errno, | |
493 NGX_HTTP_NOT_FOUND, failed, path->data); | |
1116 | 494 } |
495 | |
496 | |
497 static ngx_int_t | |
498 ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path) | |
499 { | |
500 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0, | |
501 "http delete dir: \"%s\"", path->data); | |
502 | |
503 if (ngx_delete_dir(path->data) == NGX_FILE_ERROR) { | |
504 | |
505 /* TODO: add to 207 */ | |
506 | |
507 (void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_delete_dir_n, | |
508 path->data); | |
509 } | |
510 | |
511 return NGX_OK; | |
512 } | |
513 | |
514 | |
515 static ngx_int_t | |
516 ngx_http_dav_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path) | |
517 { | |
518 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0, | |
519 "http delete file: \"%s\"", path->data); | |
520 | |
521 if (ngx_delete_file(path->data) == NGX_FILE_ERROR) { | |
522 | |
523 /* TODO: add to 207 */ | |
524 | |
525 (void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_delete_file_n, | |
526 path->data); | |
527 } | |
528 | |
529 return NGX_OK; | |
530 } | |
531 | |
532 | |
533 static ngx_int_t | |
1820 | 534 ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path) |
535 { | |
536 return NGX_OK; | |
537 } | |
538 | |
539 | |
540 static ngx_int_t | |
1116 | 541 ngx_http_dav_mkcol_handler(ngx_http_request_t *r, ngx_http_dav_loc_conf_t *dlcf) |
542 { | |
1819
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
543 u_char *p; |
1116 | 544 size_t root; |
545 ngx_str_t path; | |
546 | |
547 if (r->headers_in.content_length_n > 0) { | |
1819
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
548 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
549 "MKCOL with body is unsupported"); |
1116 | 550 return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE; |
551 } | |
552 | |
1819
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
553 if (r->uri.data[r->uri.len - 1] != '/') { |
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
554 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
555 "MKCOL can create a collection only"); |
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
556 return NGX_HTTP_CONFLICT; |
1116 | 557 } |
558 | |
1819
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
559 p = ngx_http_map_uri_to_path(r, &path, &root, 0); |
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
560 |
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
561 *(p - 1) = '\0'; |
1116 | 562 |
563 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
564 "http mkcol path: \"%s\"", path.data); | |
565 | |
566 if (ngx_create_dir(path.data, ngx_dir_access(dlcf->access)) | |
567 != NGX_FILE_ERROR) | |
568 { | |
569 if (ngx_http_dav_location(r, path.data) != NGX_OK) { | |
570 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
571 } | |
572 | |
573 return NGX_HTTP_CREATED; | |
574 } | |
575 | |
576 return ngx_http_dav_error(r->connection->log, ngx_errno, | |
1819
0f907513dd3c
change status code, add log message, and test collection URI
Igor Sysoev <igor@sysoev.ru>
parents:
1818
diff
changeset
|
577 NGX_HTTP_CONFLICT, ngx_create_dir_n, path.data); |
1116 | 578 } |
579 | |
580 | |
581 static ngx_int_t | |
582 ngx_http_dav_copy_move_handler(ngx_http_request_t *r) | |
583 { | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
584 u_char *p, *desthost, *last, ch; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
585 size_t len, root; |
1116 | 586 ngx_err_t err; |
587 ngx_int_t rc, depth; | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
588 ngx_uint_t overwrite, slash, dir; |
1116 | 589 ngx_str_t path, uri; |
590 ngx_tree_ctx_t tree; | |
591 ngx_file_info_t fi; | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
592 ngx_table_elt_t *host, *dest, *over; |
1116 | 593 ngx_http_dav_copy_ctx_t copy; |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
594 ngx_http_dav_loc_conf_t *dlcf; |
1116 | 595 |
596 if (r->headers_in.content_length_n > 0) { | |
597 return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE; | |
598 } | |
599 | |
600 dest = r->headers_in.destination; | |
601 | |
602 if (dest == NULL) { | |
603 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
604 "client sent no \"Destination\" header"); | |
605 return NGX_HTTP_BAD_REQUEST; | |
606 } | |
607 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
608 host = r->headers_in.host; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
609 |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
610 if (host == NULL) { |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
611 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
612 "client sent no \"Host\" header"); |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
613 return NGX_HTTP_BAD_REQUEST; |
1116 | 614 } |
615 | |
616 #if (NGX_HTTP_SSL) | |
617 | |
618 if (r->connection->ssl) { | |
619 if (ngx_strncmp(dest->value.data, "https://", sizeof("https://") - 1) | |
620 != 0) | |
621 { | |
622 goto invalid_destination; | |
623 } | |
624 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
625 desthost = dest->value.data + sizeof("https://") - 1; |
1116 | 626 |
627 } else | |
628 #endif | |
629 { | |
630 if (ngx_strncmp(dest->value.data, "http://", sizeof("http://") - 1) | |
631 != 0) | |
632 { | |
633 goto invalid_destination; | |
634 } | |
635 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
636 desthost = dest->value.data + sizeof("http://") - 1; |
1116 | 637 } |
638 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
639 len = r->headers_in.host_name_len; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
640 |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
641 if (ngx_strncmp(desthost, host->value.data, len) != 0) { |
1116 | 642 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1822
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
643 "\"Destination\" URI \"%V\" is handled by " |
1116 | 644 "different repository than the source URI", |
645 &dest->value); | |
646 return NGX_HTTP_BAD_REQUEST; | |
647 } | |
648 | |
649 last = dest->value.data + dest->value.len; | |
650 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1803
diff
changeset
|
651 for (p = desthost + len; p < last; p++) { |
1116 | 652 if (*p == '/') { |
653 goto destination_done; | |
654 } | |
655 } | |
656 | |
657 invalid_destination: | |
658 | |
659 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
660 "client sent invalid \"Destination\" header: \"%V\"", | |
661 &dest->value); | |
662 return NGX_HTTP_BAD_REQUEST; | |
663 | |
664 destination_done: | |
665 | |
1822
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
666 if ((r->uri.data[r->uri.len - 1] == '/' && *(last - 1) != '/') |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
667 || (r->uri.data[r->uri.len - 1] != '/' && *(last - 1) == '/')) |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
668 { |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
669 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
670 "both URI \"%V\" and \"Destination\" URI \"%V\" " |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
671 "should be either collections or non-collections", |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
672 &r->uri, &dest->value); |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
673 return NGX_HTTP_CONFLICT; |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
674 } |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
675 |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
676 depth = ngx_http_dav_depth(r, NGX_HTTP_DAV_INFINITY_DEPTH); |
1116 | 677 |
1822
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
678 if (depth != NGX_HTTP_DAV_INFINITY_DEPTH) { |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
679 |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
680 if (r->method == NGX_HTTP_COPY) { |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
681 if (depth != 0) { |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
682 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
683 "\"Depth\" header must be 0 or infinity"); |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
684 return NGX_HTTP_BAD_REQUEST; |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
685 } |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
686 |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
687 } else { |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
688 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
689 "\"Depth\" header must be infinity"); |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
690 return NGX_HTTP_BAD_REQUEST; |
935427c55e04
test URI/Destination collection/non-collection and Depth
Igor Sysoev <igor@sysoev.ru>
parents:
1821
diff
changeset
|
691 } |
1116 | 692 } |
1174
6be5ee17d80b
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1116
diff
changeset
|
693 |
1116 | 694 over = r->headers_in.overwrite; |
695 | |
696 if (over) { | |
697 if (over->value.len == 1) { | |
698 ch = over->value.data[0]; | |
699 | |
700 if (ch == 'T' || ch == 't') { | |
701 overwrite = 1; | |
702 goto overwrite_done; | |
703 } | |
704 | |
705 if (ch == 'F' || ch == 'f') { | |
706 overwrite = 0; | |
707 goto overwrite_done; | |
708 } | |
709 | |
710 } | |
711 | |
712 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
713 "client sent invalid \"Overwrite\" header: \"%V\"", | |
714 &over->value); | |
715 return NGX_HTTP_BAD_REQUEST; | |
716 } | |
717 | |
718 overwrite = 1; | |
719 | |
720 overwrite_done: | |
721 | |
722 ngx_http_map_uri_to_path(r, &path, &root, 0); | |
723 | |
724 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
725 "http copy from: \"%s\"", path.data); | |
726 | |
727 uri = r->uri; | |
728 | |
729 r->uri.len = last - p; | |
730 r->uri.data = p; | |
731 | |
732 ngx_http_map_uri_to_path(r, ©.path, &root, 0); | |
733 | |
734 r->uri = uri; | |
735 | |
736 copy.path.len--; /* omit "\0" */ | |
737 | |
738 if (copy.path.data[copy.path.len - 1] == '/') { | |
739 slash = 1; | |
740 copy.path.len--; | |
741 copy.path.data[copy.path.len] = '\0'; | |
742 | |
743 } else { | |
744 slash = 0; | |
745 } | |
746 | |
747 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
748 "http copy to: \"%s\"", copy.path.data); | |
749 | |
750 if (ngx_file_info(copy.path.data, &fi) == -1) { | |
751 err = ngx_errno; | |
752 | |
753 if (err != NGX_ENOENT) { | |
754 return ngx_http_dav_error(r->connection->log, err, | |
755 NGX_HTTP_NOT_FOUND, ngx_file_info_n, | |
756 copy.path.data); | |
757 } | |
758 | |
759 /* destination does not exist */ | |
760 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
761 overwrite = 0; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
762 dir = 0; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
763 |
1116 | 764 } else { |
765 | |
766 /* destination exists */ | |
767 | |
768 if (ngx_is_dir(&fi) && !slash) { | |
1824 | 769 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
770 "\"%V\" could not be %Ved to collection \"%V\"", | |
771 &r->uri, &r->method_name, &dest->value); | |
1116 | 772 return NGX_HTTP_CONFLICT; |
773 } | |
774 | |
775 if (!overwrite) { | |
1824 | 776 ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_EEXIST, |
777 "\"%s\" could not be created", copy.path.data); | |
1116 | 778 return NGX_HTTP_PRECONDITION_FAILED; |
779 } | |
780 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
781 dir = ngx_is_dir(&fi); |
1116 | 782 } |
783 | |
784 if (ngx_file_info(path.data, &fi) == -1) { | |
785 return ngx_http_dav_error(r->connection->log, ngx_errno, | |
786 NGX_HTTP_NOT_FOUND, ngx_file_info_n, | |
787 path.data); | |
788 } | |
789 | |
790 if (ngx_is_dir(&fi)) { | |
791 | |
792 if (r->uri.data[r->uri.len - 1] != '/') { | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
793 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
794 "\"%V\" is collection", &r->uri); |
1116 | 795 return NGX_HTTP_BAD_REQUEST; |
796 } | |
797 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
798 if (overwrite) { |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
799 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
800 "http delete: \"%s\"", copy.path.data); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
801 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
802 rc = ngx_http_dav_delete_path(r, ©.path, dir); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
803 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
804 if (rc != NGX_OK) { |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
805 return rc; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
806 } |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
807 } |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
808 } |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
809 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
810 if (ngx_is_dir(&fi)) { |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
811 |
1116 | 812 path.len -= 2; /* omit "/\0" */ |
813 | |
814 if (r->method == NGX_HTTP_MOVE) { | |
815 if (ngx_rename_file(path.data, copy.path.data) != NGX_FILE_ERROR) { | |
816 return NGX_HTTP_CREATED; | |
817 } | |
818 } | |
819 | |
820 if (ngx_create_dir(copy.path.data, ngx_file_access(&fi)) | |
821 == NGX_FILE_ERROR) | |
822 { | |
823 return ngx_http_dav_error(r->connection->log, ngx_errno, | |
824 NGX_HTTP_NOT_FOUND, | |
825 ngx_create_dir_n, copy.path.data); | |
826 } | |
827 | |
828 copy.len = path.len; | |
829 | |
1769
a35bc4007ec3
tree.init_handler is never called
Igor Sysoev <igor@sysoev.ru>
parents:
1749
diff
changeset
|
830 tree.init_handler = NULL; |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
831 tree.file_handler = ngx_http_dav_copy_tree_file; |
1116 | 832 tree.pre_tree_handler = ngx_http_dav_copy_dir; |
833 tree.post_tree_handler = ngx_http_dav_copy_dir_time; | |
834 tree.spec_handler = ngx_http_dav_noop; | |
835 tree.data = © | |
836 tree.alloc = 0; | |
837 tree.log = r->connection->log; | |
838 | |
839 if (ngx_walk_tree(&tree, &path) == NGX_OK) { | |
840 | |
841 if (r->method == NGX_HTTP_MOVE) { | |
842 rc = ngx_http_dav_delete_path(r, &path, 1); | |
843 | |
844 if (rc != NGX_OK) { | |
845 return rc; | |
846 } | |
847 } | |
848 | |
849 return NGX_HTTP_CREATED; | |
850 } | |
851 | |
852 } else { | |
853 | |
854 if (r->method == NGX_HTTP_MOVE) { | |
855 if (ngx_rename_file(path.data, copy.path.data) != NGX_FILE_ERROR) { | |
856 return NGX_HTTP_NO_CONTENT; | |
857 } | |
858 } | |
859 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
860 dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
861 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
862 tree.size = ngx_file_size(&fi); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
863 tree.mtime = ngx_file_mtime(&fi); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
864 tree.access = dlcf->access; |
1116 | 865 tree.log = r->connection->log; |
866 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
867 if (ngx_http_dav_copy_file(&tree, path.data, copy.path.data) == NGX_OK) |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
868 { |
1116 | 869 if (r->method == NGX_HTTP_MOVE) { |
870 rc = ngx_http_dav_delete_path(r, &path, 0); | |
871 | |
872 if (rc != NGX_OK) { | |
873 return rc; | |
874 } | |
875 } | |
876 | |
877 return NGX_HTTP_NO_CONTENT; | |
878 } | |
879 } | |
880 | |
881 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
882 } | |
883 | |
884 | |
885 static ngx_int_t | |
886 ngx_http_dav_copy_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path) | |
887 { | |
888 u_char *p, *dir; | |
889 size_t len; | |
890 ngx_http_dav_copy_ctx_t *copy; | |
891 | |
892 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0, | |
893 "http copy dir: \"%s\"", path->data); | |
894 | |
895 copy = ctx->data; | |
896 | |
897 len = copy->path.len + path->len; | |
898 | |
899 dir = ngx_alloc(len + 1, ctx->log); | |
900 if (dir == NULL) { | |
901 return NGX_ABORT; | |
902 } | |
903 | |
904 p = ngx_cpymem(dir, copy->path.data, copy->path.len); | |
905 (void) ngx_cpystrn(p, path->data + copy->len, path->len - copy->len + 1); | |
906 | |
907 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0, | |
908 "http copy dir to: \"%s\"", dir); | |
909 | |
910 if (ngx_create_dir(dir, ngx_dir_access(ctx->access)) == NGX_FILE_ERROR) { | |
911 (void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_create_dir_n, | |
912 dir); | |
913 } | |
914 | |
915 ngx_free(dir); | |
916 | |
917 return NGX_OK; | |
918 } | |
919 | |
920 | |
921 static ngx_int_t | |
922 ngx_http_dav_copy_dir_time(ngx_tree_ctx_t *ctx, ngx_str_t *path) | |
923 { | |
924 u_char *p, *dir; | |
925 size_t len; | |
926 ngx_http_dav_copy_ctx_t *copy; | |
927 | |
928 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0, | |
929 "http copy dir time: \"%s\"", path->data); | |
930 | |
931 copy = ctx->data; | |
932 | |
933 len = copy->path.len + path->len; | |
934 | |
935 dir = ngx_alloc(len + 1, ctx->log); | |
936 if (dir == NULL) { | |
937 return NGX_ABORT; | |
938 } | |
939 | |
940 p = ngx_cpymem(dir, copy->path.data, copy->path.len); | |
941 (void) ngx_cpystrn(p, path->data + copy->len, path->len - copy->len + 1); | |
942 | |
943 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0, | |
944 "http copy dir time to: \"%s\"", dir); | |
945 | |
1803
7405719e4848
condition declarations inside blocks update missed in r1705
Igor Sysoev <igor@sysoev.ru>
parents:
1769
diff
changeset
|
946 #if (NGX_WIN32) |
7405719e4848
condition declarations inside blocks update missed in r1705
Igor Sysoev <igor@sysoev.ru>
parents:
1769
diff
changeset
|
947 { |
7405719e4848
condition declarations inside blocks update missed in r1705
Igor Sysoev <igor@sysoev.ru>
parents:
1769
diff
changeset
|
948 ngx_fd_t fd; |
1116 | 949 |
950 fd = ngx_open_file(dir, NGX_FILE_RDWR, NGX_FILE_OPEN, 0); | |
951 | |
952 if (fd == NGX_INVALID_FILE) { | |
953 (void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_open_file_n, dir); | |
954 goto failed; | |
955 } | |
956 | |
957 if (ngx_set_file_time(NULL, fd, ctx->mtime) != NGX_OK) { | |
958 ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno, | |
959 ngx_set_file_time_n " \"%s\" failed", dir); | |
960 } | |
961 | |
962 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
963 ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno, | |
964 ngx_close_file_n " \"%s\" failed", dir); | |
965 } | |
1803
7405719e4848
condition declarations inside blocks update missed in r1705
Igor Sysoev <igor@sysoev.ru>
parents:
1769
diff
changeset
|
966 } |
1116 | 967 |
968 failed: | |
969 | |
970 #else | |
971 | |
972 if (ngx_set_file_time(dir, 0, ctx->mtime) != NGX_OK) { | |
973 ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno, | |
974 ngx_set_file_time_n " \"%s\" failed", dir); | |
975 } | |
976 | |
977 #endif | |
978 | |
979 ngx_free(dir); | |
980 | |
981 return NGX_OK; | |
982 } | |
983 | |
984 | |
985 static ngx_int_t | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
986 ngx_http_dav_copy_tree_file(ngx_tree_ctx_t *ctx, ngx_str_t *path) |
1116 | 987 { |
988 u_char *p, *file; | |
989 size_t len; | |
990 ngx_http_dav_copy_ctx_t *copy; | |
991 | |
992 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0, | |
993 "http copy file: \"%s\"", path->data); | |
994 | |
995 copy = ctx->data; | |
996 | |
997 len = copy->path.len + path->len; | |
998 | |
999 file = ngx_alloc(len + 1, ctx->log); | |
1000 if (file == NULL) { | |
1001 return NGX_ABORT; | |
1002 } | |
1003 | |
1004 p = ngx_cpymem(file, copy->path.data, copy->path.len); | |
1005 (void) ngx_cpystrn(p, path->data + copy->len, path->len - copy->len + 1); | |
1006 | |
1007 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0, | |
1008 "http copy file to: \"%s\"", file); | |
1009 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1010 (void) ngx_http_dav_copy_file(ctx, path->data, file); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1011 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1012 ngx_free(file); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1013 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1014 return NGX_OK; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1015 } |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1016 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1017 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1018 static ngx_int_t |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1019 ngx_http_dav_copy_file(ngx_tree_ctx_t *ctx, u_char *from, u_char *to) |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1020 { |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1021 off_t size; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1022 ssize_t n; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1023 ngx_fd_t fd, cfd; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1024 ngx_int_t rc; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1025 u_char buf[NGX_HTTP_DAV_COPY_BLOCK]; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1026 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1027 fd = ngx_open_file(from, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0); |
1116 | 1028 |
1029 if (fd == NGX_INVALID_FILE) { | |
1030 (void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_open_file_n, | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1031 from); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1032 return NGX_ERROR; |
1116 | 1033 } |
1034 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1035 cfd = ngx_open_file(to, NGX_FILE_WRONLY, NGX_FILE_CREATE_OR_OPEN, |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1036 ctx->access); |
1116 | 1037 |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1038 rc = NGX_ERROR; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1039 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1040 if (cfd == NGX_INVALID_FILE) { |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1041 (void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_open_file_n, to); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1042 goto failed; |
1116 | 1043 } |
1044 | |
1045 for (size = ctx->size; size > 0; size -= n) { | |
1046 | |
1047 n = ngx_read_fd(fd, buf, NGX_HTTP_DAV_COPY_BLOCK); | |
1048 | |
1049 if (n == NGX_FILE_ERROR) { | |
1050 ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno, | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1051 ngx_read_fd_n " \"%s\" failed", from); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1052 goto failed; |
1116 | 1053 } |
1054 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1055 if (ngx_write_fd(cfd, buf, n) == NGX_FILE_ERROR) { |
1116 | 1056 ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno, |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1057 ngx_write_fd_n " \"%s\" failed", to); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1058 goto failed; |
1116 | 1059 } |
1060 } | |
1061 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1062 if (ngx_set_file_time(to, cfd, ctx->mtime) != NGX_OK) { |
1116 | 1063 ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno, |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1064 ngx_set_file_time_n " \"%s\" failed", to); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1065 goto failed; |
1116 | 1066 } |
1067 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1068 if (ngx_close_file(cfd) == NGX_FILE_ERROR) { |
1116 | 1069 ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno, |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1070 ngx_close_file_n " \"%s\" failed", to); |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1071 goto failed; |
1116 | 1072 } |
1073 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1074 rc = NGX_OK; |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1075 |
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1076 failed: |
1116 | 1077 |
1078 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
1079 ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno, | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1080 ngx_close_file_n " \"%s\" failed", from); |
1116 | 1081 } |
1082 | |
1825
2e0fbfef56d4
do not delete target until all tests will be done,
Igor Sysoev <igor@sysoev.ru>
parents:
1824
diff
changeset
|
1083 return rc; |
1116 | 1084 } |
1085 | |
1086 | |
1087 static ngx_int_t | |
1088 ngx_http_dav_depth(ngx_http_request_t *r, ngx_int_t dflt) | |
1089 { | |
1090 ngx_table_elt_t *depth; | |
1174
6be5ee17d80b
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1116
diff
changeset
|
1091 |
1116 | 1092 depth = r->headers_in.depth; |
1093 | |
1094 if (depth == NULL) { | |
1095 return dflt; | |
1096 } | |
1097 | |
1098 if (depth->value.len == 1) { | |
1099 | |
1100 if (depth->value.data[0] == '0') { | |
1101 return 0; | |
1102 } | |
1103 | |
1104 if (depth->value.data[0] == '1') { | |
1105 return 1; | |
1106 } | |
1107 | |
1108 } else { | |
1109 | |
1110 if (depth->value.len == sizeof("infinity") - 1 | |
1111 && ngx_strcmp(depth->value.data, "infinity") == 0) | |
1112 { | |
1113 return NGX_HTTP_DAV_INFINITY_DEPTH; | |
1114 } | |
1115 } | |
1116 | |
1117 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1118 "client sent invalid \"Depth\" header: \"%V\"", | |
1119 &depth->value); | |
1120 | |
1121 return NGX_HTTP_DAV_INVALID_DEPTH; | |
1122 } | |
1123 | |
1124 | |
1125 static ngx_int_t | |
1126 ngx_http_dav_error(ngx_log_t *log, ngx_err_t err, ngx_int_t not_found, | |
637 | 1127 char *failed, u_char *path) |
1128 { | |
1129 ngx_int_t rc; | |
1130 ngx_uint_t level; | |
1131 | |
1132 if (err == NGX_ENOENT || err == NGX_ENOTDIR || err == NGX_ENAMETOOLONG) { | |
1133 level = NGX_LOG_ERR; | |
1134 rc = not_found; | |
1135 | |
1136 } else if (err == NGX_EACCES || err == NGX_EPERM) { | |
1137 level = NGX_LOG_ERR; | |
1138 rc = NGX_HTTP_FORBIDDEN; | |
1139 | |
1140 } else if (err == NGX_EEXIST) { | |
1141 level = NGX_LOG_ERR; | |
1142 rc = NGX_HTTP_NOT_ALLOWED; | |
1143 | |
1144 } else if (err == NGX_ENOSPC) { | |
1145 level = NGX_LOG_CRIT; | |
1146 rc = NGX_HTTP_INSUFFICIENT_STORAGE; | |
1147 | |
1148 } else { | |
1149 level = NGX_LOG_CRIT; | |
1150 rc = NGX_HTTP_INTERNAL_SERVER_ERROR; | |
1151 } | |
1152 | |
1116 | 1153 ngx_log_error(level, log, err, "%s \"%s\" failed", failed, path); |
637 | 1154 |
1155 return rc; | |
1156 } | |
1157 | |
1158 | |
1159 static ngx_int_t | |
1160 ngx_http_dav_location(ngx_http_request_t *r, u_char *path) | |
1161 { | |
1162 u_char *location; | |
1163 ngx_http_core_loc_conf_t *clcf; | |
1164 | |
1165 r->headers_out.location = ngx_palloc(r->pool, sizeof(ngx_table_elt_t)); | |
1166 if (r->headers_out.location == NULL) { | |
1167 return NGX_ERROR; | |
1168 } | |
1169 | |
1170 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
1171 | |
1172 if (!clcf->alias && clcf->root_lengths == NULL) { | |
1173 location = path + clcf->root.len; | |
1174 | |
1175 } else { | |
1176 location = ngx_palloc(r->pool, r->uri.len); | |
1177 if (location == NULL) { | |
1178 return NGX_ERROR; | |
1179 } | |
1180 | |
1181 ngx_memcpy(location, r->uri.data, r->uri.len); | |
1182 } | |
1183 | |
1184 /* | |
1185 * we do not need to set the r->headers_out.location->hash and | |
1186 * r->headers_out.location->key fields | |
1187 */ | |
1188 | |
1189 r->headers_out.location->value.len = r->uri.len; | |
1190 r->headers_out.location->value.data = location; | |
1191 | |
1192 return NGX_OK; | |
1193 } | |
1194 | |
1195 | |
633 | 1196 static void * |
1197 ngx_http_dav_create_loc_conf(ngx_conf_t *cf) | |
1198 { | |
1199 ngx_http_dav_loc_conf_t *conf; | |
1200 | |
1201 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_dav_loc_conf_t)); | |
1202 if (conf == NULL) { | |
1203 return NGX_CONF_ERROR; | |
1204 } | |
1205 | |
1206 /* | |
1207 * set by ngx_pcalloc(): | |
1208 * | |
1209 * conf->methods = 0; | |
1210 */ | |
1211 | |
1816 | 1212 conf->min_delete_depth = NGX_CONF_UNSET; |
1213 conf->access = NGX_CONF_UNSET_UINT; | |
637 | 1214 conf->create_full_put_path = NGX_CONF_UNSET; |
1215 | |
633 | 1216 return conf; |
1217 } | |
1218 | |
1219 | |
1220 static char * | |
1221 ngx_http_dav_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
1222 { | |
1223 ngx_http_dav_loc_conf_t *prev = parent; | |
1224 ngx_http_dav_loc_conf_t *conf = child; | |
1225 | |
1226 ngx_conf_merge_bitmask_value(conf->methods, prev->methods, | |
637 | 1227 (NGX_CONF_BITMASK_SET|NGX_HTTP_DAV_OFF)); |
1228 | |
1816 | 1229 ngx_conf_merge_uint_value(conf->min_delete_depth, |
1230 prev->min_delete_depth, 0); | |
633 | 1231 |
669 | 1232 ngx_conf_merge_uint_value(conf->access, prev->access, 0600); |
1233 | |
1816 | 1234 ngx_conf_merge_value(conf->create_full_put_path, |
1235 prev->create_full_put_path, 0); | |
1236 | |
633 | 1237 return NGX_CONF_OK; |
1238 } | |
1239 | |
1240 | |
1241 static ngx_int_t | |
681 | 1242 ngx_http_dav_init(ngx_conf_t *cf) |
633 | 1243 { |
1244 ngx_http_handler_pt *h; | |
1245 ngx_http_core_main_conf_t *cmcf; | |
1246 | |
681 | 1247 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); |
633 | 1248 |
1249 h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers); | |
1250 if (h == NULL) { | |
1251 return NGX_ERROR; | |
1252 } | |
1253 | |
1254 *h = ngx_http_dav_handler; | |
1255 | |
1256 return NGX_OK; | |
1257 } |