소스 검색

Make session ID header name configurable

tags/v0.7
Valery Kholodkov 17 년 전
부모
커밋
6c63c538c0
1개의 변경된 파일15개의 추가작업 그리고 4개의 파일을 삭제
  1. 15
    4
      ngx_http_uploadprogress_module.c

+ 15
- 4
ngx_http_uploadprogress_module.c 파일 보기

@@ -64,6 +64,7 @@ typedef struct {
64 64
     u_char                           track;
65 65
     ngx_str_t                        content_type;
66 66
     ngx_array_t                      templates;
67
+    ngx_str_t                        header;
67 68
 } ngx_http_uploadprogress_conf_t;
68 69
 
69 70
 typedef struct {
@@ -131,6 +132,13 @@ static ngx_command_t ngx_http_uploadprogress_commands[] = {
131 132
      0,
132 133
      NULL},
133 134
 
135
+    {ngx_string("upload_progress_header"),
136
+     NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
137
+     ngx_conf_set_str_slot,
138
+     NGX_HTTP_LOC_CONF_OFFSET,
139
+     offsetof(ngx_http_uploadprogress_conf_t, header),
140
+     NULL},
141
+
134 142
     ngx_null_command
135 143
 };
136 144
 
@@ -165,8 +173,6 @@ ngx_module_t                     ngx_http_uploadprogress_module = {
165 173
     NGX_MODULE_V1_PADDING
166 174
 };
167 175
 
168
-static ngx_str_t x_progress_id = ngx_string("X-Progress-ID");
169
-
170 176
 static ngx_http_uploadprogress_state_map_t ngx_http_uploadprogress_state_map[] = {
171 177
     {ngx_string("starting"),  uploadprogress_state_starting},
172 178
     {ngx_string("error"),     uploadprogress_state_error},
@@ -198,6 +204,9 @@ get_tracking_id(ngx_http_request_t * r)
198 204
     ngx_list_part_t                 *part;
199 205
     ngx_table_elt_t                 *header;
200 206
     ngx_str_t                       *ret, args;
207
+    ngx_http_uploadprogress_conf_t  *upcf;
208
+
209
+    upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
201 210
 
202 211
     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "upload-progress: get_tracking_id");
203 212
 
@@ -216,8 +225,8 @@ get_tracking_id(ngx_http_request_t * r)
216 225
             i = 0;
217 226
         }
218 227
 
219
-        if (header[i].key.len == x_progress_id.len
220
-            && ngx_strncasecmp(header[i].key.data, x_progress_id.data,
228
+        if (header[i].key.len == upcf->header.len
229
+            && ngx_strncasecmp(header[i].key.data, upcf->header.data,
221 230
                            header[i].key.len) == 0) {
222 231
             ret = ngx_calloc(sizeof(ngx_str_t), r->connection->log );
223 232
             ret->data = header[i].value.data;
@@ -1254,6 +1263,8 @@ ngx_http_uploadprogress_merge_loc_conf(ngx_conf_t * cf, void *parent, void *chil
1254 1263
         }
1255 1264
     } 
1256 1265
 
1266
+    ngx_conf_merge_str_value(conf->header, prev->header, "X-Progress-ID");
1267
+
1257 1268
     return NGX_CONF_OK;
1258 1269
 }
1259 1270
 

Loading…
취소
저장