Mercurial > hg > nginx-ranges
diff src/http/modules/ngx_http_log_module.c @ 578:f3a9e57d2e17
Merge with current.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 11 Mar 2010 21:27:17 +0300 |
parents | 5c576ea5dbd9 |
children | 8246d8a2c2be |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_log_module.c +++ b/src/http/modules/ngx_http_log_module.c @@ -542,8 +542,25 @@ ngx_http_log_request_time(ngx_http_reque static u_char * ngx_http_log_status(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) { - return ngx_sprintf(buf, "%ui", - r->err_status ? r->err_status : r->headers_out.status); + ngx_uint_t status; + + if (r->err_status) { + status = r->err_status; + + } else if (r->headers_out.status) { + status = r->headers_out.status; + + } else if (r->http_version == NGX_HTTP_VERSION_9) { + *buf++ = '0'; + *buf++ = '0'; + *buf++ = '9'; + return buf; + + } else { + status = 0; + } + + return ngx_sprintf(buf, "%ui", status); } @@ -650,7 +667,7 @@ ngx_http_log_variable(ngx_http_request_t static uintptr_t ngx_http_log_escape(u_char *dst, u_char *src, size_t size) { - ngx_uint_t i, n; + ngx_uint_t n; static u_char hex[] = "0123456789ABCDEF"; static uint32_t escape[] = { @@ -678,17 +695,18 @@ ngx_http_log_escape(u_char *dst, u_char n = 0; - for (i = 0; i < size; i++) { + while (size) { if (escape[*src >> 5] & (1 << (*src & 0x1f))) { n++; } src++; + size--; } return (uintptr_t) n; } - for (i = 0; i < size; i++) { + while (size) { if (escape[*src >> 5] & (1 << (*src & 0x1f))) { *dst++ = '\\'; *dst++ = 'x'; @@ -699,6 +717,7 @@ ngx_http_log_escape(u_char *dst, u_char } else { *dst++ = *src++; } + size--; } return (uintptr_t) dst;