Mercurial > hg > nginx-ranges
comparison src/http/modules/ngx_http_autoindex_handler.c @ 8:983306b77348 NGINX_0_1_4
nginx 0.1.4
*) Bugfix: in the ngx_http_autoindex_module.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 26 Oct 2004 00:00:00 +0400 |
parents | 80ba094c6b3e |
children | 46833bd150cb |
comparison
equal
deleted
inserted
replaced
7:2cb393a33bee | 8:983306b77348 |
---|---|
228 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 228 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
229 "http autoindex file: \"%s\"", ngx_de_name(&dir)); | 229 "http autoindex file: \"%s\"", ngx_de_name(&dir)); |
230 | 230 |
231 len = ngx_de_namelen(&dir); | 231 len = ngx_de_namelen(&dir); |
232 | 232 |
233 if (len == 1 && ngx_de_name(&dir)[0] == '.') { | |
234 continue; | |
235 } | |
236 | |
237 if (len == 2 | |
238 && ngx_de_name(&dir)[0] == '.' | |
239 && ngx_de_name(&dir)[0] == '.') | |
240 { | |
241 continue; | |
242 } | |
243 | |
233 if (!dir.valid_info) { | 244 if (!dir.valid_info) { |
234 | 245 |
235 if (dname.len + 1 + len > fname.len) { | 246 if (dname.len + 1 + len > fname.len) { |
236 fname.len = dname.len + 1 + len + 32; | 247 fname.len = dname.len + 1 + len + 32; |
237 | 248 |
249 if (ngx_de_info(fname.data, &dir) == NGX_FILE_ERROR) { | 260 if (ngx_de_info(fname.data, &dir) == NGX_FILE_ERROR) { |
250 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, | 261 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, |
251 ngx_de_info_n " \"%s\" failed", fname.data); | 262 ngx_de_info_n " \"%s\" failed", fname.data); |
252 return ngx_http_autoindex_error(r, &dir, dname.data); | 263 return ngx_http_autoindex_error(r, &dir, dname.data); |
253 } | 264 } |
254 } | |
255 | |
256 if (len == 1 && ngx_de_name(&dir)[0] == '.') { | |
257 continue; | |
258 } | |
259 | |
260 if (len == 2 | |
261 && ngx_de_name(&dir)[0] == '.' | |
262 && ngx_de_name(&dir)[0] == '.') | |
263 { | |
264 continue; | |
265 } | 265 } |
266 | 266 |
267 if (!(entry = ngx_array_push(&entries))) { | 267 if (!(entry = ngx_array_push(&entries))) { |
268 return ngx_http_autoindex_error(r, &dir, dname.data); | 268 return ngx_http_autoindex_error(r, &dir, dname.data); |
269 } | 269 } |
373 b->last = ngx_cpymem(b->last, " -", sizeof(" -") - 1); | 373 b->last = ngx_cpymem(b->last, " -", sizeof(" -") - 1); |
374 | 374 |
375 } else { | 375 } else { |
376 length = entry[i].size; | 376 length = entry[i].size; |
377 | 377 |
378 if (length > 999999999) { | 378 if (length > 1024 * 1024 * 1024) { |
379 size = (ngx_int_t) length / 1024 * 1024 * 1024; | 379 size = (ngx_int_t) (length / (1024 * 1024 * 1024)); |
380 if ((length % 1024 * 1024 * 1024) | 380 if ((length % (1024 * 1024 * 1024)) |
381 > (1024 * 1024 * 1024 / 2 - 1)) | 381 > (1024 * 1024 * 1024 / 2 - 1)) |
382 { | 382 { |
383 size++; | 383 size++; |
384 } | 384 } |
385 scale = 'G'; | 385 scale = 'G'; |
386 | 386 |
387 } else if (length > 999999) { | 387 } else if (length > 1024 * 1024) { |
388 size = (ngx_int_t) length / 1024 * 1024; | 388 size = (ngx_int_t) (length / (1024 * 1024)); |
389 if ((length % 1024 * 1024) > (1024 * 1024 / 2 - 1)) { | 389 if ((length % (1024 * 1024)) > (1024 * 1024 / 2 - 1)) { |
390 size++; | 390 size++; |
391 } | 391 } |
392 scale = 'M'; | 392 scale = 'M'; |
393 | 393 |
394 } else if (length > 9999) { | 394 } else if (length > 9999) { |
395 size = (ngx_int_t) length / 1024; | 395 size = (ngx_int_t) (length / 1024); |
396 if (length % 1024 > 511) { | 396 if (length % 1024 > 511) { |
397 size++; | 397 size++; |
398 } | 398 } |
399 scale = 'K'; | 399 scale = 'K'; |
400 | 400 |
412 | 412 |
413 *b->last++ = CR; | 413 *b->last++ = CR; |
414 *b->last++ = LF; | 414 *b->last++ = LF; |
415 } | 415 } |
416 | 416 |
417 /* TODO: free temporary pool */ | |
418 | |
417 b->last = ngx_cpymem(b->last, "</pre><hr>", sizeof("</pre><hr>") - 1); | 419 b->last = ngx_cpymem(b->last, "</pre><hr>", sizeof("</pre><hr>") - 1); |
418 | 420 |
419 b->last = ngx_cpymem(b->last, tail, sizeof(tail) - 1); | 421 b->last = ngx_cpymem(b->last, tail, sizeof(tail) - 1); |
420 | 422 |
421 r->headers_out.status = NGX_HTTP_OK; | 423 r->headers_out.status = NGX_HTTP_OK; |