]> git.kaiwu.me - nginx.git/commitdiff
$request_body_file
authorIgor Sysoev <igor@sysoev.ru>
Tue, 10 Oct 2006 15:50:08 +0000 (15:50 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 10 Oct 2006 15:50:08 +0000 (15:50 +0000)
src/http/ngx_http_variables.c

index 374a29e709c111305b0e2aba47201ae149f715ac..9dee6ee9e2180dd8d9629362bb0449e081f8941d 100644 (file)
@@ -50,6 +50,8 @@ static ngx_int_t ngx_http_variable_body_bytes_sent(ngx_http_request_t *r,
     ngx_http_variable_value_t *v, uintptr_t data);
 static ngx_int_t ngx_http_variable_request_completion(ngx_http_request_t *r,
     ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_request_body_file(ngx_http_request_t *r,
+    ngx_http_variable_value_t *v, uintptr_t data);
 
 static ngx_int_t ngx_http_variable_sent_content_type(ngx_http_request_t *r,
     ngx_http_variable_value_t *v, uintptr_t data);
@@ -170,6 +172,10 @@ static ngx_http_variable_t  ngx_http_core_variables[] = {
       ngx_http_variable_request_completion,
       0, 0, 0 },
 
+    { ngx_string("request_body_file"), NULL,
+      ngx_http_variable_request_body_file,
+      0, 0, 0 },
+
     { ngx_string("sent_http_content_type"), NULL,
       ngx_http_variable_sent_content_type, 0, 0, 0 },
 
@@ -1134,6 +1140,30 @@ ngx_http_variable_request_completion(ngx_http_request_t *r,
 }
 
 
+static ngx_int_t
+ngx_http_variable_request_body_file(ngx_http_request_t *r,
+    ngx_http_variable_value_t *v, uintptr_t data)
+{
+    if (r->request_body == NULL || r->request_body->temp_file == NULL) {
+        v->len = 0;
+        v->valid = 1;
+        v->no_cachable = 0;
+        v->not_found = 0;
+        v->data = (u_char *) "";
+
+        return NGX_OK;
+    }
+
+    v->len = r->request_body->temp_file->file.name.len;
+    v->valid = 1;
+    v->no_cachable = 0;
+    v->not_found = 0;
+    v->data = r->request_body->temp_file->file.name.data;
+
+    return NGX_OK;
+}
+
+
 ngx_int_t
 ngx_http_variables_add_core_vars(ngx_conf_t *cf)
 {