Welcome! Log In Create A New Profile

Advanced

[nginx] svn commit: r4749 - in trunk/src/http: . modules

Anonymous User
July 08, 2012 08:14PM
Author: mdounin
Date: 2012-07-09 00:13:06 +0000 (Mon, 09 Jul 2012)
New Revision: 4749
URL: http://trac.nginx.org/nginx/changeset/4749/nginx

Log:
Entity tags: set for static respones.


Modified:
trunk/src/http/modules/ngx_http_flv_module.c
trunk/src/http/modules/ngx_http_gzip_static_module.c
trunk/src/http/modules/ngx_http_mp4_module.c
trunk/src/http/modules/ngx_http_static_module.c
trunk/src/http/ngx_http_core_module.c
trunk/src/http/ngx_http_core_module.h

Modified: trunk/src/http/modules/ngx_http_flv_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_flv_module.c 2012-07-07 21:24:01 UTC (rev 4748)
+++ trunk/src/http/modules/ngx_http_flv_module.c 2012-07-09 00:13:06 UTC (rev 4749)
@@ -194,6 +194,10 @@
r->headers_out.content_length_n = len;
r->headers_out.last_modified_time = of.mtime;

+ if (ngx_http_set_etag(r) != NGX_OK) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
if (ngx_http_set_content_type(r) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

Modified: trunk/src/http/modules/ngx_http_gzip_static_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_gzip_static_module.c 2012-07-07 21:24:01 UTC (rev 4748)
+++ trunk/src/http/modules/ngx_http_gzip_static_module.c 2012-07-09 00:13:06 UTC (rev 4749)
@@ -207,6 +207,10 @@
r->headers_out.content_length_n = of.size;
r->headers_out.last_modified_time = of.mtime;

+ if (ngx_http_set_etag(r) != NGX_OK) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
if (ngx_http_set_content_type(r) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

Modified: trunk/src/http/modules/ngx_http_mp4_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_mp4_module.c 2012-07-07 21:24:01 UTC (rev 4748)
+++ trunk/src/http/modules/ngx_http_mp4_module.c 2012-07-09 00:13:06 UTC (rev 4749)
@@ -586,6 +586,10 @@
r->headers_out.status = NGX_HTTP_OK;
r->headers_out.last_modified_time = of.mtime;

+ if (ngx_http_set_etag(r) != NGX_OK) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
if (ngx_http_set_content_type(r) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

Modified: trunk/src/http/modules/ngx_http_static_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_static_module.c 2012-07-07 21:24:01 UTC (rev 4748)
+++ trunk/src/http/modules/ngx_http_static_module.c 2012-07-09 00:13:06 UTC (rev 4749)
@@ -220,6 +220,10 @@
r->headers_out.content_length_n = of.size;
r->headers_out.last_modified_time = of.mtime;

+ if (ngx_http_set_etag(r) != NGX_OK) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
if (ngx_http_set_content_type(r) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

Modified: trunk/src/http/ngx_http_core_module.c
===================================================================
--- trunk/src/http/ngx_http_core_module.c 2012-07-07 21:24:01 UTC (rev 4748)
+++ trunk/src/http/ngx_http_core_module.c 2012-07-09 00:13:06 UTC (rev 4749)
@@ -1809,6 +1809,35 @@


ngx_int_t
+ngx_http_set_etag(ngx_http_request_t *r)
+{
+ ngx_table_elt_t *etag;
+
+ etag = ngx_list_push(&r->headers_out.headers);
+ if (etag == NULL) {
+ return NGX_ERROR;
+ }
+
+ etag->hash = 1;
+ ngx_str_set(&etag->key, "ETag");
+
+ etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3);
+ if (etag->value.data == NULL) {
+ return NGX_ERROR;
+ }
+
+ etag->value.len = ngx_sprintf(etag->value.data, "\"%xT-%xO\"",
+ r->headers_out.last_modified_time,
+ r->headers_out.content_length_n)
+ - etag->value.data;
+
+ r->headers_out.etag = etag;
+
+ return NGX_OK;
+}
+
+
+ngx_int_t
ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
ngx_str_t *ct, ngx_http_complex_value_t *cv)
{

Modified: trunk/src/http/ngx_http_core_module.h
===================================================================
--- trunk/src/http/ngx_http_core_module.h 2012-07-07 21:24:01 UTC (rev 4748)
+++ trunk/src/http/ngx_http_core_module.h 2012-07-09 00:13:06 UTC (rev 4749)
@@ -480,6 +480,7 @@
void *ngx_http_test_content_type(ngx_http_request_t *r, ngx_hash_t *types_hash);
ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
void ngx_http_set_exten(ngx_http_request_t *r);
+ngx_int_t ngx_http_set_etag(ngx_http_request_t *r);
ngx_int_t ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
ngx_str_t *ct, ngx_http_complex_value_t *cv);
u_char *ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *name,

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] svn commit: r4749 - in trunk/src/http: . modules

Anonymous User 1222 July 08, 2012 08:14PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 245
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready