diff src/http/modules/ngx_http_dav_module.c @ 2007:b9de93d804ea

*) host in request line has priority *) allow several Host headers *) validate host
author Igor Sysoev <igor@sysoev.ru>
date Thu, 15 May 2008 14:44:47 +0000
parents cbd321d1e1b3
children 2a92804f4109
line wrap: on
line diff
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -512,7 +512,7 @@ ngx_http_dav_mkcol_handler(ngx_http_requ
 static ngx_int_t
 ngx_http_dav_copy_move_handler(ngx_http_request_t *r)
 {
-    u_char                   *p, *desthost, *last, ch;
+    u_char                   *p, *host, *last, ch;
     size_t                    len, root;
     ngx_err_t                 err;
     ngx_int_t                 rc, depth;
@@ -520,7 +520,7 @@ ngx_http_dav_copy_move_handler(ngx_http_
     ngx_str_t                 path, uri;
     ngx_tree_ctx_t            tree;
     ngx_file_info_t           fi;
-    ngx_table_elt_t          *host, *dest, *over;
+    ngx_table_elt_t          *dest, *over;
     ngx_http_dav_copy_ctx_t   copy;
     ngx_http_dav_loc_conf_t  *dlcf;
 
@@ -536,9 +536,9 @@ ngx_http_dav_copy_move_handler(ngx_http_
         return NGX_HTTP_BAD_REQUEST;
     }
 
-    host = r->headers_in.host;
+    len = r->headers_in.server.len;
 
-    if (host == NULL) {
+    if (len == 0) {
         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                       "client sent no \"Host\" header");
         return NGX_HTTP_BAD_REQUEST;
@@ -553,7 +553,7 @@ ngx_http_dav_copy_move_handler(ngx_http_
             goto invalid_destination;
         }
 
-        desthost = dest->value.data + sizeof("https://") - 1;
+        host = dest->value.data + sizeof("https://") - 1;
 
     } else
 #endif
@@ -564,12 +564,10 @@ ngx_http_dav_copy_move_handler(ngx_http_
             goto invalid_destination;
         }
 
-        desthost = dest->value.data + sizeof("http://") - 1;
+        host = dest->value.data + sizeof("http://") - 1;
     }
 
-    len = r->headers_in.host_name_len;
-
-    if (ngx_strncmp(desthost, host->value.data, len) != 0) {
+    if (ngx_strncmp(host, r->headers_in.server.data, len) != 0) {
         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                       "\"Destination\" URI \"%V\" is handled by "
                       "different repository than the source URI",
@@ -579,7 +577,7 @@ ngx_http_dav_copy_move_handler(ngx_http_
 
     last = dest->value.data + dest->value.len;
 
-    for (p = desthost + len; p < last; p++) {
+    for (p = host + len; p < last; p++) {
         if (*p == '/') {
             goto destination_done;
         }