]> git.kaiwu.me - nginx.git/commitdiff
r2183, r2192 merge:
authorIgor Sysoev <igor@sysoev.ru>
Thu, 20 Nov 2008 17:07:22 +0000 (17:07 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Thu, 20 Nov 2008 17:07:22 +0000 (17:07 +0000)
*) allow file existence test for POST requests in static module
*) do not discard body while error_page redirection

src/http/modules/ngx_http_static_module.c
src/http/ngx_http_special_response.c

index c4e688ffbca501ada90b284a5cf583db161ba3cc..b8ad57336a3e5ed4639e606e2f31c47444efbc11 100644 (file)
@@ -58,7 +58,7 @@ ngx_http_static_handler(ngx_http_request_t *r)
     ngx_open_file_info_t       of;
     ngx_http_core_loc_conf_t  *clcf;
 
-    if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
+    if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) {
         return NGX_HTTP_NOT_ALLOWED;
     }
 
@@ -71,12 +71,6 @@ ngx_http_static_handler(ngx_http_request_t *r)
         return NGX_DECLINED;
     }
 
-    rc = ngx_http_discard_request_body(r);
-
-    if (rc != NGX_OK) {
-        return rc;
-    }
-
     log = r->connection->log;
 
     /*
@@ -186,6 +180,16 @@ ngx_http_static_handler(ngx_http_request_t *r)
 
 #endif
 
+    if (r->method & NGX_HTTP_POST) {
+        return NGX_HTTP_NOT_ALLOWED;
+    }
+
+    rc = ngx_http_discard_request_body(r);
+
+    if (rc != NGX_OK) {
+        return rc;
+    }
+
     log->action = "sending response to client";
 
     r->headers_out.status = NGX_HTTP_OK;
index 11c41d55b0ec8d11f29b783fb54160fa913043f6..3ef5c7cdae77618b275a9c968d8b44a82f1ffdcf 100644 (file)
@@ -327,7 +327,6 @@ static ngx_str_t  ngx_http_get_name = { 3, (u_char *) "GET " };
 ngx_int_t
 ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
 {
-    ngx_int_t                  rc;
     ngx_uint_t                 i, err;
     ngx_http_err_page_t       *err_page;
     ngx_http_core_loc_conf_t  *clcf;
@@ -335,12 +334,6 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
     ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                    "http special response: %d, \"%V\"", error, &r->uri);
 
-    rc = ngx_http_discard_request_body(r);
-
-    if (rc == NGX_HTTP_INTERNAL_SERVER_ERROR) {
-        error = NGX_HTTP_INTERNAL_SERVER_ERROR;
-    }
-
     r->err_status = error;
 
     if (r->keepalive != 0) {
@@ -385,6 +378,10 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
         }
     }
 
+    if (ngx_http_discard_request_body(r) != NGX_OK) {
+        error = NGX_HTTP_INTERNAL_SERVER_ERROR;
+    }
+
     if (clcf->msie_refresh
         && r->headers_in.msie
         && (error == NGX_HTTP_MOVED_PERMANENTLY