Procházet zdrojové kódy

Added directive to specify content type of progress report

tags/v0.7
Valery Kholodkov před 17 roky
rodič
revize
7b3ef91c10
1 změnil soubory, kde provedl 11 přidání a 2 odebrání
  1. 11
    2
      ngx_http_uploadprogress_module.c

+ 11
- 2
ngx_http_uploadprogress_module.c Zobrazit soubor

@@ -44,6 +44,7 @@ typedef struct {
44 44
     ngx_event_t                      cleanup;
45 45
     ngx_http_handler_pt              handler;
46 46
     u_char                           track;
47
+    ngx_str_t                        content_type;
47 48
 } ngx_http_uploadprogress_conf_t;
48 49
 
49 50
 typedef struct {
@@ -88,6 +89,13 @@ static ngx_command_t ngx_http_uploadprogress_commands[] = {
88 89
      0,
89 90
      NULL},
90 91
 
92
+    {ngx_string("upload_progress_content_type"),
93
+     NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
94
+     ngx_conf_set_str_slot,
95
+     NGX_HTTP_LOC_CONF_OFFSET,
96
+     offsetof(ngx_http_uploadprogress_conf_t, content_type),
97
+     NULL},
98
+
91 99
     ngx_null_command
92 100
 };
93 101
 
@@ -460,8 +468,7 @@ ngx_http_reportuploads_handler(ngx_http_request_t * r)
460 468
 	ngx_free(id);
461 469
 
462 470
     /* send the output */
463
-    r->headers_out.content_type.len = sizeof("text/javascript") - 1;
464
-    r->headers_out.content_type.data = (u_char *) "text/javascript";
471
+    r->headers_out.content_type = upcf->content_type;
465 472
 
466 473
     /* force no-cache */
467 474
     expires = r->headers_out.expires;
@@ -1127,6 +1134,8 @@ ngx_http_uploadprogress_merge_loc_conf(ngx_conf_t * cf, void *parent, void *chil
1127 1134
         *conf = *prev;
1128 1135
     }
1129 1136
 
1137
+    ngx_conf_merge_str_value(conf->content_type, prev->content_type, "text/javascript");
1138
+
1130 1139
     return NGX_CONF_OK;
1131 1140
 }
1132 1141
 

Načítá se…
Zrušit
Uložit