Explorar el Código

fix IE lowercase x-progress-id in XMLHttpRequest

tags/v0.3
Brice Figureau hace 18 años
padre
commit
d7009cadf5
Se han modificado 1 ficheros con 31 adiciones y 5 borrados
  1. 31
    5
      ngx_http_uploadprogress_module.c

+ 31
- 5
ngx_http_uploadprogress_module.c Ver fichero

@@ -124,6 +124,8 @@ get_tracking_id(ngx_http_request_t * r)
124 124
     ngx_table_elt_t                 *header;
125 125
     ngx_str_t                       *ret;
126 126
 
127
+    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "upload-progress: get_tracking_id");
128
+
127 129
     part = &r->headers_in.headers.part;
128 130
     header = part->elts;
129 131
 
@@ -140,20 +142,40 @@ get_tracking_id(ngx_http_request_t * r)
140 142
         }
141 143
 
142 144
         if (header[i].key.len == x_progress_id.len
143
-            && ngx_strncmp(header[i].key.data, x_progress_id.data,
145
+            && ngx_strncasecmp(header[i].key.data, x_progress_id.data,
144 146
                            header[i].key.len) == 0) {
145 147
             ret = ngx_pcalloc(r->pool, sizeof(ngx_str_t));
146 148
             ret->data = header[i].value.data;
147 149
             ret->len = header[i].value.len;
150
+				    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 
151
+			                     "upload-progress: get_tracking_id found header: %V", ret);
148 152
             return ret;
149 153
         }
150 154
     }
151 155
 
156
+		ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 
157
+		               "upload-progress: get_tracking_id no header found");
158
+
152 159
     /* not found, check as a reaquest arg */
153 160
     if (r->args.len) {
154
-        p = (u_char *) ngx_strstr(r->args.data, "X-Progress-ID=");
155
-
156
-        if (p) {
161
+        ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 
162
+                       "upload-progress: get_tracking_id no header found but args present");
163
+        i = 0;
164
+        p = r->args.data;
165
+        do {
166
+            ngx_uint_t len = r->args.len - (p - r->args.data);
167
+            if (len >= 14 && ngx_strncasecmp(p, (u_char*)"X-Progress-ID=", 14) == 0) {
168
+              ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 
169
+                             "upload-progress: get_tracking_id found args: %s",p);
170
+                i = 1;
171
+                break;
172
+            }
173
+            if (len<=0)
174
+                break;
175
+        } 
176
+        while(p++);
177
+				
178
+        if (i) {
157 179
             start_p = p += 14;
158 180
             while (p < r->args.data + r->args.len) {
159 181
                 if (*p++ != '&') {
@@ -164,10 +186,14 @@ get_tracking_id(ngx_http_request_t * r)
164 186
             ret = ngx_pcalloc(r->pool, sizeof(ngx_str_t));
165 187
             ret->data = start_p;
166 188
             ret->len = p - start_p;
189
+						ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 
190
+						               "upload-progress: get_tracking_id found args: %V",ret);
167 191
             return ret;
168 192
         }
169 193
     }
170
-
194
+		
195
+		ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 
196
+		               "upload-progress: get_tracking_id no id found");
171 197
     return NULL;
172 198
 }
173 199
 

Loading…
Cancelar
Guardar