diff options
author | Igor Sysoev <igor@sysoev.ru> | 2010-06-18 15:17:07 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2010-06-18 15:17:07 +0000 |
commit | 082d9965a39f4f20f2781ce2e0ccd2c6edfac575 (patch) | |
tree | 47e8faeaf24e9a31cdb7f64c6f57c41f85ef6f7a | |
parent | b2ee47c0c70483e6dfd867b63d04bce6718df3e3 (diff) | |
download | nginx-082d9965a39f4f20f2781ce2e0ccd2c6edfac575.tar.gz nginx-082d9965a39f4f20f2781ce2e0ccd2c6edfac575.zip |
use ngx_http_send_response() in empty_gif
-rw-r--r-- | src/http/modules/ngx_http_empty_gif_module.c | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/src/http/modules/ngx_http_empty_gif_module.c b/src/http/modules/ngx_http_empty_gif_module.c index 35c4415b3..a896bd4b6 100644 --- 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_request_t *r) 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); - } - - b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); - if (b == NULL) { - return NGX_HTTP_INTERNAL_SERVER_ERROR; - } + ngx_memzero(&cv, sizeof(ngx_http_complex_value_t)); - 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); } |