# HG changeset patch # User Igor Sysoev # Date 1276874227 0 # Node ID c0113b6648de9dc6c786adca48561ceef4db20b1 # Parent 40e356cf4176dc7cb2e3384f8bb810cdfc8e60f5 use ngx_http_send_response() in empty_gif diff --git a/src/http/modules/ngx_http_empty_gif_module.c b/src/http/modules/ngx_http_empty_gif_module.c --- a/src/http/modules/ngx_http_empty_gif_module.c +++ b/src/http/modules/ngx_http_empty_gif_module.c @@ -105,12 +105,14 @@ ngx_module_t ngx_http_empty_gif_module }; +static ngx_str_t ngx_http_gif_type = ngx_string("image/gif"); + + static ngx_int_t ngx_http_empty_gif_handler(ngx_http_request_t *r) { - ngx_int_t rc; - ngx_buf_t *b; - ngx_chain_t out; + ngx_int_t rc; + ngx_http_complex_value_t cv; if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) { return NGX_HTTP_NOT_ALLOWED; @@ -122,41 +124,13 @@ ngx_http_empty_gif_handler(ngx_http_requ return rc; } - r->headers_out.content_type_len = sizeof("image/gif") - 1; - ngx_str_set(&r->headers_out.content_type, "image/gif"); - - if (r->method == NGX_HTTP_HEAD) { - r->headers_out.status = NGX_HTTP_OK; - r->headers_out.content_length_n = sizeof(ngx_empty_gif); - r->headers_out.last_modified_time = 23349600; - - return ngx_http_send_header(r); - } + ngx_memzero(&cv, sizeof(ngx_http_complex_value_t)); - b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); - if (b == NULL) { - return NGX_HTTP_INTERNAL_SERVER_ERROR; - } - - out.buf = b; - out.next = NULL; - - b->pos = ngx_empty_gif; - b->last = ngx_empty_gif + sizeof(ngx_empty_gif); - b->memory = 1; - b->last_buf = 1; - - r->headers_out.status = NGX_HTTP_OK; - r->headers_out.content_length_n = sizeof(ngx_empty_gif); + cv.value.len = sizeof(ngx_empty_gif); + cv.value.data = ngx_empty_gif; r->headers_out.last_modified_time = 23349600; - rc = ngx_http_send_header(r); - - if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { - return rc; - } - - return ngx_http_output_filter(r, &out); + return ngx_http_send_response(r, NGX_HTTP_OK, &ngx_http_gif_type, &cv); }