mirror of
https://github.com/nginx/nginx.git
synced 2025-06-17 01:01:28 +08:00
log DELETE errors
This commit is contained in:
parent
0ce17d2b5b
commit
b06db4283a
@ -345,12 +345,15 @@ static ngx_int_t
|
|||||||
ngx_http_dav_delete_handler(ngx_http_request_t *r)
|
ngx_http_dav_delete_handler(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
size_t root;
|
size_t root;
|
||||||
|
ngx_err_t err;
|
||||||
ngx_int_t rc, depth;
|
ngx_int_t rc, depth;
|
||||||
ngx_uint_t dir;
|
ngx_uint_t dir;
|
||||||
ngx_str_t path;
|
ngx_str_t path;
|
||||||
ngx_file_info_t fi;
|
ngx_file_info_t fi;
|
||||||
|
|
||||||
if (r->headers_in.content_length_n > 0) {
|
if (r->headers_in.content_length_n > 0) {
|
||||||
|
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||||
|
"DELETE with body is unsupported");
|
||||||
return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE;
|
return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,21 +363,27 @@ ngx_http_dav_delete_handler(ngx_http_request_t *r)
|
|||||||
"http delete filename: \"%s\"", path.data);
|
"http delete filename: \"%s\"", path.data);
|
||||||
|
|
||||||
if (ngx_file_info(path.data, &fi) == -1) {
|
if (ngx_file_info(path.data, &fi) == -1) {
|
||||||
return ngx_http_dav_error(r->connection->log, ngx_errno,
|
err = ngx_errno;
|
||||||
NGX_HTTP_NOT_FOUND, ngx_file_info_n,
|
|
||||||
path.data);
|
rc = (err == NGX_ENOTDIR) ? NGX_HTTP_CONFLICT : NGX_HTTP_NOT_FOUND;
|
||||||
|
|
||||||
|
return ngx_http_dav_error(r->connection->log, err,
|
||||||
|
rc, ngx_file_info_n, path.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_is_dir(&fi)) {
|
if (ngx_is_dir(&fi)) {
|
||||||
|
|
||||||
if (r->uri.data[r->uri.len - 1] != '/') {
|
if (r->uri.data[r->uri.len - 1] != '/') {
|
||||||
/* TODO: 301 */
|
ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_EISDIR,
|
||||||
return NGX_HTTP_BAD_REQUEST;
|
"DELETE \"%s\" failed", path.data);
|
||||||
|
return NGX_HTTP_CONFLICT;
|
||||||
}
|
}
|
||||||
|
|
||||||
depth = ngx_http_dav_depth(r, NGX_HTTP_DAV_INFINITY_DEPTH);
|
depth = ngx_http_dav_depth(r, NGX_HTTP_DAV_INFINITY_DEPTH);
|
||||||
|
|
||||||
if (depth != NGX_HTTP_DAV_INFINITY_DEPTH) {
|
if (depth != NGX_HTTP_DAV_INFINITY_DEPTH) {
|
||||||
|
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||||
|
"\"Depth\" header must be infinity");
|
||||||
return NGX_HTTP_BAD_REQUEST;
|
return NGX_HTTP_BAD_REQUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,6 +396,8 @@ ngx_http_dav_delete_handler(ngx_http_request_t *r)
|
|||||||
depth = ngx_http_dav_depth(r, 0);
|
depth = ngx_http_dav_depth(r, 0);
|
||||||
|
|
||||||
if (depth != 0 && depth != NGX_HTTP_DAV_INFINITY_DEPTH) {
|
if (depth != 0 && depth != NGX_HTTP_DAV_INFINITY_DEPTH) {
|
||||||
|
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||||
|
"\"Depth\" header must be 0 or infinity");
|
||||||
return NGX_HTTP_BAD_REQUEST;
|
return NGX_HTTP_BAD_REQUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user