Browse files

releng work for v0.06.

  • Loading branch information...
1 parent f681127 commit 19875bb17ad195c8ea6a37cb884c05dfdc3174ca @agentzh agentzh committed Jan 29, 2010
View
33 README
@@ -6,9 +6,9 @@ Name
installation instructions.
Version
- This document describes memc-nginx-module v0.05
+ This document describes memc-nginx-module v0.06
(<http://github.com/agentzh/memc-nginx-module/downloads>) released on
- Dec 24, 2009.
+ Jan 29, 2010.
Synopsis
# GET /foo?key=dog
@@ -78,6 +78,16 @@ Synopsis
}
...
+ # read the memcached flags into the Last-Modified header
+ # to respond 304 to conditional GET
+ location /memc {
+ set $memc_key $arg_key;
+
+ memc_pass 127.0.0.1:11984;
+
+ memc_flags_to_last_modified on;
+ }
+
Description
This module extends the standard memcached module to support almost the
whole memcached TCP protocol
@@ -343,8 +353,16 @@ Directives
memc_cmds_allowed get;
}
- Then "/foo?cmd=set&key=foo&val=bar" and "/foo?cmd=flush_all" will both
- fail and yield "403 Forbidden".
+ memc_flags_to_last_modified
+ syntax: *memc_flags_to_last_modified on|off*
+
+ default: *off*
+
+ context: *http, server, location, if*
+
+ Read the memcached flags as epoch seconds and set it as the value of the
+ "Last-Modified" header. For conditional GET, it will signal nginx to
+ return "304 Not Modified" response to save bandwidth.
Installation
Grab the nginx source code from nginx.net (<http://nginx.net/>), for
@@ -379,7 +397,7 @@ Installation
Compatibility
The following versions of Nginx should work with this module:
- * 0.8.x (last tested version is 0.8.31)
+ * 0.8.x (last tested version is 0.8.32)
* 0.7.x >= 0.7.46 (last tested version is 0.7.64)
@@ -409,6 +427,11 @@ Source Repository
(<http://github.com/agentzh/memc-nginx-module>).
ChangeLog
+ v0.06
+ * implemented the memc_flags_to_last_modified directive.
+
+ * added a new variable named $memc_flags_as_http_time.
+
v0.05
* removed the "memc_bind" directive since it won't compile with nginx
0.8.31.
View
31 doc/readme.wiki
@@ -6,7 +6,7 @@
= Version =
-This document describes memc-nginx-module [http://github.com/agentzh/memc-nginx-module/downloads v0.05] released on Dec 24, 2009.
+This document describes memc-nginx-module [http://github.com/agentzh/memc-nginx-module/downloads v0.06] released on Jan 29, 2010.
= Synopsis =
@@ -85,6 +85,18 @@ This document describes memc-nginx-module [http://github.com/agentzh/memc-nginx-
...
</geshi>
+<geshi lang="nginx">
+ # read the memcached flags into the Last-Modified header
+ # to respond 304 to conditional GET
+ location /memc {
+ set $memc_key $arg_key;
+
+ memc_pass 127.0.0.1:11984;
+
+ memc_flags_to_last_modified on;
+ }
+</geshi>
+
= Description =
This module extends the standard [[NginxHttpMemcachedModule|memcached module]] to support almost the whole [http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt memcached TCP protocol].
@@ -339,7 +351,14 @@ An example is
}
</geshi>
-Then <code>/foo?cmd=set&key=foo&val=bar</code> and <code>/foo?cmd=flush_all</code> will both fail and yield <code>403 Forbidden</code>.
+== memc_flags_to_last_modified ==
+'''syntax:''' ''memc_flags_to_last_modified on|off''
+
+'''default:''' ''off''
+
+'''context:''' ''http, server, location, if''
+
+Read the memcached flags as epoch seconds and set it as the value of the <code>Last-Modified</code> header. For conditional GET, it will signal nginx to return <code>304 Not Modified</code> response to save bandwidth.
= Installation =
@@ -374,7 +393,7 @@ regenerate the parser's C file, i.e., [http://github.com/agentzh/memc-nginx-modu
The following versions of Nginx should work with this module:
-* '''0.8.x''' (last tested version is 0.8.31)
+* '''0.8.x''' (last tested version is 0.8.32)
* '''0.7.x >= 0.7.46''' (last tested version is 0.7.64)
It's worth mentioning that some 0.7.x versions older than 0.7.46 might also work, but I can't easily test them because the test suite makes extensive use of the [[NginxHttpEchoModule|echo module]]'s [[NginxHttpEchoModule#echo_location|echo_location directive]], which requires at least nginx 0.7.46 :)
@@ -396,8 +415,12 @@ Available on github at [http://github.com/agentzh/memc-nginx-module agentzh/memc
= ChangeLog =
+== v0.06 ==
+* implemented the [[#memc_flags_to_last_modified|memc_flags_to_last_modified]] directive.
+* added a new variable named [[#$memc_flags_as_http_time|$memc_flags_as_http_time]].
+
== v0.05 ==
-* removed the "memc_bind" directive since it won't compile with nginx 0.8.31.
+* removed the <code>memc_bind</code> directive since it won't compile with nginx 0.8.31.
== v0.04 ==
* to ensure Maxim's [http://mdounin.ru/hg/ngx_http_upstream_keepalive/ ngx_http_upstream_keepalive] module caches our connections even if <code>u->headers_in->status</code> is 201 (Created).
View
12 src/ngx_http_memc_module.c
@@ -110,6 +110,13 @@ static ngx_command_t ngx_http_memc_commands[] = {
0,
NULL },
+ { ngx_string("memc_flags_to_last_modified"),
+ NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_memc_loc_conf_t, flags_to_last_modified),
+ NULL },
+
ngx_null_command
};
@@ -166,6 +173,8 @@ ngx_http_memc_create_loc_conf(ngx_conf_t *cf)
* conf->upstream.location = NULL;
*/
+ conf->flags_to_last_modified = NGX_CONF_UNSET;
+
conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC;
conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC;
conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC;
@@ -196,6 +205,9 @@ ngx_http_memc_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_http_memc_loc_conf_t *prev = parent;
ngx_http_memc_loc_conf_t *conf = child;
+ ngx_conf_merge_value(conf->flags_to_last_modified,
+ prev->flags_to_last_modified, 0);
+
ngx_conf_merge_msec_value(conf->upstream.connect_timeout,
prev->upstream.connect_timeout, 60000);
View
1 src/ngx_http_memc_module.h
@@ -34,6 +34,7 @@ typedef enum {
} ngx_http_memc_cmd_t;
typedef struct {
+ ngx_flag_t flags_to_last_modified;
ngx_http_upstream_conf_t upstream;
ngx_array_t *cmds_allowed;
} ngx_http_memc_loc_conf_t;
View
148 src/ngx_http_memc_response.c
@@ -446,6 +446,7 @@ ngx_http_memc_get_cmd_filter(void *data, ssize_t bytes)
ngx_int_t
ngx_http_memc_process_get_cmd_header(ngx_http_request_t *r)
{
+ ngx_http_memc_loc_conf_t *conf;
u_char *p, *len;
ngx_str_t line;
ngx_http_upstream_t *u;
@@ -516,6 +517,13 @@ ngx_http_memc_process_get_cmd_header(ngx_http_request_t *r)
while (*p) {
if (*p++ == ' ') {
flags_vv->len = p - 1 - flags_vv->data;
+ conf = ngx_http_get_module_loc_conf(r, ngx_http_memc_module);
+
+ if (conf->flags_to_last_modified) {
+ r->headers_out.last_modified_time = ngx_atotm(flags_vv->data,
+ flags_vv->len);
+ }
+
goto length;
}
}
@@ -598,11 +606,11 @@ parse_memc_storage(int *cs_addr, u_char *p, u_char *pe, ngx_uint_t *status_addr,
int cs = *cs_addr;
-#line 497 "src/ngx_http_memc_response.rl"
+#line 505 "src/ngx_http_memc_response.rl"
-#line 498 "src/ngx_http_memc_response.rl"
+#line 506 "src/ngx_http_memc_response.rl"
-#line 606 "src/ngx_http_memc_response.c"
+#line 614 "src/ngx_http_memc_response.c"
{
if ( p == pe )
goto _test_eof;
@@ -770,7 +778,7 @@ case 15:
if ( ++p == pe )
goto _test_eof54;
case 54:
-#line 774 "src/ngx_http_memc_response.c"
+#line 782 "src/ngx_http_memc_response.c"
goto st0;
st16:
if ( ++p == pe )
@@ -1103,7 +1111,7 @@ case 53:
_out: {}
}
-#line 499 "src/ngx_http_memc_response.rl"
+#line 507 "src/ngx_http_memc_response.rl"
*cs_addr = cs;
@@ -1117,11 +1125,11 @@ parse_memc_flush_all(int *cs_addr, u_char *p, u_char *pe, ngx_uint_t *status_add
int cs = *cs_addr;
-#line 512 "src/ngx_http_memc_response.rl"
+#line 520 "src/ngx_http_memc_response.rl"
-#line 513 "src/ngx_http_memc_response.rl"
+#line 521 "src/ngx_http_memc_response.rl"
-#line 1125 "src/ngx_http_memc_response.c"
+#line 1133 "src/ngx_http_memc_response.c"
{
if ( p == pe )
goto _test_eof;
@@ -1263,7 +1271,7 @@ case 15:
if ( ++p == pe )
goto _test_eof30;
case 30:
-#line 1267 "src/ngx_http_memc_response.c"
+#line 1275 "src/ngx_http_memc_response.c"
goto st0;
st16:
if ( ++p == pe )
@@ -1398,7 +1406,7 @@ case 29:
_out: {}
}
-#line 514 "src/ngx_http_memc_response.rl"
+#line 522 "src/ngx_http_memc_response.rl"
*cs_addr = cs;
@@ -1412,11 +1420,11 @@ parse_memc_version(int *cs_addr, u_char *p, u_char *pe, ngx_uint_t *status_addr,
int cs = *cs_addr;
-#line 527 "src/ngx_http_memc_response.rl"
+#line 535 "src/ngx_http_memc_response.rl"
-#line 528 "src/ngx_http_memc_response.rl"
+#line 536 "src/ngx_http_memc_response.rl"
-#line 1420 "src/ngx_http_memc_response.c"
+#line 1428 "src/ngx_http_memc_response.c"
{
if ( p == pe )
goto _test_eof;
@@ -1551,7 +1559,7 @@ case 15:
if ( ++p == pe )
goto _test_eof39;
case 39:
-#line 1555 "src/ngx_http_memc_response.c"
+#line 1563 "src/ngx_http_memc_response.c"
goto st0;
st16:
if ( ++p == pe )
@@ -1713,7 +1721,7 @@ case 36:
if ( ++p == pe )
goto _test_eof40;
case 40:
-#line 1717 "src/ngx_http_memc_response.c"
+#line 1725 "src/ngx_http_memc_response.c"
if ( (*p) == 13 )
goto st36;
goto st35;
@@ -1776,7 +1784,7 @@ case 38:
_out: {}
}
-#line 529 "src/ngx_http_memc_response.rl"
+#line 537 "src/ngx_http_memc_response.rl"
*cs_addr = cs;
@@ -1790,11 +1798,11 @@ parse_memc_stats(int *cs_addr, u_char *p, u_char *pe, ngx_uint_t *status_addr, n
int cs = *cs_addr;
-#line 542 "src/ngx_http_memc_response.rl"
+#line 550 "src/ngx_http_memc_response.rl"
-#line 543 "src/ngx_http_memc_response.rl"
+#line 551 "src/ngx_http_memc_response.rl"
-#line 1798 "src/ngx_http_memc_response.c"
+#line 1806 "src/ngx_http_memc_response.c"
{
if ( p == pe )
goto _test_eof;
@@ -1935,7 +1943,7 @@ case 15:
if ( ++p == pe )
goto _test_eof43;
case 43:
-#line 1939 "src/ngx_http_memc_response.c"
+#line 1947 "src/ngx_http_memc_response.c"
goto st0;
st16:
if ( ++p == pe )
@@ -2137,7 +2145,7 @@ case 40:
if ( ++p == pe )
goto _test_eof44;
case 44:
-#line 2141 "src/ngx_http_memc_response.c"
+#line 2149 "src/ngx_http_memc_response.c"
switch( (*p) ) {
case 13: goto st35;
case 69: goto st37;
@@ -2206,7 +2214,7 @@ case 42:
_out: {}
}
-#line 544 "src/ngx_http_memc_response.rl"
+#line 552 "src/ngx_http_memc_response.rl"
*cs_addr = cs;
@@ -2220,11 +2228,11 @@ parse_memc_delete(int *cs_addr, u_char *p, u_char *pe, ngx_uint_t *status_addr,
int cs = *cs_addr;
-#line 557 "src/ngx_http_memc_response.rl"
+#line 565 "src/ngx_http_memc_response.rl"
-#line 558 "src/ngx_http_memc_response.rl"
+#line 566 "src/ngx_http_memc_response.rl"
-#line 2228 "src/ngx_http_memc_response.c"
+#line 2236 "src/ngx_http_memc_response.c"
{
if ( p == pe )
goto _test_eof;
@@ -2380,7 +2388,7 @@ case 15:
if ( ++p == pe )
goto _test_eof45;
case 45:
-#line 2384 "src/ngx_http_memc_response.c"
+#line 2392 "src/ngx_http_memc_response.c"
goto st0;
st16:
if ( ++p == pe )
@@ -2635,7 +2643,7 @@ case 44:
_out: {}
}
-#line 559 "src/ngx_http_memc_response.rl"
+#line 567 "src/ngx_http_memc_response.rl"
*cs_addr = cs;
@@ -2649,11 +2657,11 @@ parse_memc_incr_decr(int *cs_addr, u_char *p, u_char *pe, ngx_uint_t *status_add
int cs = *cs_addr;
-#line 572 "src/ngx_http_memc_response.rl"
+#line 580 "src/ngx_http_memc_response.rl"
-#line 573 "src/ngx_http_memc_response.rl"
+#line 581 "src/ngx_http_memc_response.rl"
-#line 2657 "src/ngx_http_memc_response.c"
+#line 2665 "src/ngx_http_memc_response.c"
{
if ( p == pe )
goto _test_eof;
@@ -2682,7 +2690,7 @@ cs = 0;
if ( ++p == pe )
goto _test_eof2;
case 2:
-#line 2686 "src/ngx_http_memc_response.c"
+#line 2694 "src/ngx_http_memc_response.c"
switch( (*p) ) {
case 13: goto tr6;
case 32: goto tr7;
@@ -2700,7 +2708,7 @@ case 2:
if ( ++p == pe )
goto _test_eof3;
case 3:
-#line 2704 "src/ngx_http_memc_response.c"
+#line 2712 "src/ngx_http_memc_response.c"
if ( (*p) == 10 )
goto tr8;
goto st0;
@@ -2760,7 +2768,7 @@ case 3:
if ( ++p == pe )
goto _test_eof40;
case 40:
-#line 2764 "src/ngx_http_memc_response.c"
+#line 2772 "src/ngx_http_memc_response.c"
goto st0;
tr7:
#line 26 "src/memc_common.rl"
@@ -2772,7 +2780,7 @@ case 40:
if ( ++p == pe )
goto _test_eof4;
case 4:
-#line 2776 "src/ngx_http_memc_response.c"
+#line 2784 "src/ngx_http_memc_response.c"
switch( (*p) ) {
case 13: goto tr6;
case 32: goto tr7;
@@ -2788,7 +2796,7 @@ case 4:
if ( ++p == pe )
goto _test_eof5;
case 5:
-#line 2792 "src/ngx_http_memc_response.c"
+#line 2800 "src/ngx_http_memc_response.c"
if ( (*p) == 76 )
goto tr9;
goto st0;
@@ -2802,7 +2810,7 @@ case 5:
if ( ++p == pe )
goto _test_eof6;
case 6:
-#line 2806 "src/ngx_http_memc_response.c"
+#line 2814 "src/ngx_http_memc_response.c"
if ( (*p) == 73 )
goto tr10;
goto st0;
@@ -2816,7 +2824,7 @@ case 6:
if ( ++p == pe )
goto _test_eof7;
case 7:
-#line 2820 "src/ngx_http_memc_response.c"
+#line 2828 "src/ngx_http_memc_response.c"
if ( (*p) == 69 )
goto tr11;
goto st0;
@@ -2830,7 +2838,7 @@ case 7:
if ( ++p == pe )
goto _test_eof8;
case 8:
-#line 2834 "src/ngx_http_memc_response.c"
+#line 2842 "src/ngx_http_memc_response.c"
if ( (*p) == 78 )
goto tr12;
goto st0;
@@ -2844,7 +2852,7 @@ case 8:
if ( ++p == pe )
goto _test_eof9;
case 9:
-#line 2848 "src/ngx_http_memc_response.c"
+#line 2856 "src/ngx_http_memc_response.c"
if ( (*p) == 84 )
goto tr13;
goto st0;
@@ -2858,7 +2866,7 @@ case 9:
if ( ++p == pe )
goto _test_eof10;
case 10:
-#line 2862 "src/ngx_http_memc_response.c"
+#line 2870 "src/ngx_http_memc_response.c"
if ( (*p) == 95 )
goto tr14;
goto st0;
@@ -2872,7 +2880,7 @@ case 10:
if ( ++p == pe )
goto _test_eof11;
case 11:
-#line 2876 "src/ngx_http_memc_response.c"
+#line 2884 "src/ngx_http_memc_response.c"
if ( (*p) == 69 )
goto tr15;
goto st0;
@@ -2886,7 +2894,7 @@ case 11:
if ( ++p == pe )
goto _test_eof12;
case 12:
-#line 2890 "src/ngx_http_memc_response.c"
+#line 2898 "src/ngx_http_memc_response.c"
if ( (*p) == 82 )
goto tr16;
goto st0;
@@ -2900,7 +2908,7 @@ case 12:
if ( ++p == pe )
goto _test_eof13;
case 13:
-#line 2904 "src/ngx_http_memc_response.c"
+#line 2912 "src/ngx_http_memc_response.c"
if ( (*p) == 82 )
goto tr17;
goto st0;
@@ -2914,7 +2922,7 @@ case 13:
if ( ++p == pe )
goto _test_eof14;
case 14:
-#line 2918 "src/ngx_http_memc_response.c"
+#line 2926 "src/ngx_http_memc_response.c"
if ( (*p) == 79 )
goto tr18;
goto st0;
@@ -2928,7 +2936,7 @@ case 14:
if ( ++p == pe )
goto _test_eof15;
case 15:
-#line 2932 "src/ngx_http_memc_response.c"
+#line 2940 "src/ngx_http_memc_response.c"
if ( (*p) == 82 )
goto tr19;
goto st0;
@@ -2942,7 +2950,7 @@ case 15:
if ( ++p == pe )
goto _test_eof16;
case 16:
-#line 2946 "src/ngx_http_memc_response.c"
+#line 2954 "src/ngx_http_memc_response.c"
if ( (*p) == 32 )
goto tr20;
goto st0;
@@ -2956,7 +2964,7 @@ case 16:
if ( ++p == pe )
goto _test_eof17;
case 17:
-#line 2960 "src/ngx_http_memc_response.c"
+#line 2968 "src/ngx_http_memc_response.c"
if ( (*p) == 13 )
goto tr21;
goto tr20;
@@ -2970,7 +2978,7 @@ case 17:
if ( ++p == pe )
goto _test_eof18;
case 18:
-#line 2974 "src/ngx_http_memc_response.c"
+#line 2982 "src/ngx_http_memc_response.c"
switch( (*p) ) {
case 10: goto tr22;
case 13: goto tr21;
@@ -2986,7 +2994,7 @@ case 18:
if ( ++p == pe )
goto _test_eof19;
case 19:
-#line 2990 "src/ngx_http_memc_response.c"
+#line 2998 "src/ngx_http_memc_response.c"
if ( (*p) == 82 )
goto tr23;
goto st0;
@@ -3000,7 +3008,7 @@ case 19:
if ( ++p == pe )
goto _test_eof20;
case 20:
-#line 3004 "src/ngx_http_memc_response.c"
+#line 3012 "src/ngx_http_memc_response.c"
if ( (*p) == 82 )
goto tr24;
goto st0;
@@ -3014,7 +3022,7 @@ case 20:
if ( ++p == pe )
goto _test_eof21;
case 21:
-#line 3018 "src/ngx_http_memc_response.c"
+#line 3026 "src/ngx_http_memc_response.c"
if ( (*p) == 79 )
goto tr25;
goto st0;
@@ -3028,7 +3036,7 @@ case 21:
if ( ++p == pe )
goto _test_eof22;
case 22:
-#line 3032 "src/ngx_http_memc_response.c"
+#line 3040 "src/ngx_http_memc_response.c"
if ( (*p) == 82 )
goto tr26;
goto st0;
@@ -3042,7 +3050,7 @@ case 22:
if ( ++p == pe )
goto _test_eof23;
case 23:
-#line 3046 "src/ngx_http_memc_response.c"
+#line 3054 "src/ngx_http_memc_response.c"
if ( (*p) == 13 )
goto tr27;
goto st0;
@@ -3056,7 +3064,7 @@ case 23:
if ( ++p == pe )
goto _test_eof24;
case 24:
-#line 3060 "src/ngx_http_memc_response.c"
+#line 3068 "src/ngx_http_memc_response.c"
if ( (*p) == 10 )
goto tr22;
goto st0;
@@ -3070,7 +3078,7 @@ case 24:
if ( ++p == pe )
goto _test_eof25;
case 25:
-#line 3074 "src/ngx_http_memc_response.c"
+#line 3082 "src/ngx_http_memc_response.c"
if ( (*p) == 79 )
goto tr28;
goto st0;
@@ -3084,7 +3092,7 @@ case 25:
if ( ++p == pe )
goto _test_eof26;
case 26:
-#line 3088 "src/ngx_http_memc_response.c"
+#line 3096 "src/ngx_http_memc_response.c"
if ( (*p) == 84 )
goto tr29;
goto st0;
@@ -3098,7 +3106,7 @@ case 26:
if ( ++p == pe )
goto _test_eof27;
case 27:
-#line 3102 "src/ngx_http_memc_response.c"
+#line 3110 "src/ngx_http_memc_response.c"
if ( (*p) == 95 )
goto tr30;
goto st0;
@@ -3112,7 +3120,7 @@ case 27:
if ( ++p == pe )
goto _test_eof28;
case 28:
-#line 3116 "src/ngx_http_memc_response.c"
+#line 3124 "src/ngx_http_memc_response.c"
if ( (*p) == 70 )
goto tr31;
goto st0;
@@ -3126,7 +3134,7 @@ case 28:
if ( ++p == pe )
goto _test_eof29;
case 29:
-#line 3130 "src/ngx_http_memc_response.c"
+#line 3138 "src/ngx_http_memc_response.c"
if ( (*p) == 79 )
goto tr32;
goto st0;
@@ -3140,7 +3148,7 @@ case 29:
if ( ++p == pe )
goto _test_eof30;
case 30:
-#line 3144 "src/ngx_http_memc_response.c"
+#line 3152 "src/ngx_http_memc_response.c"
if ( (*p) == 85 )
goto tr33;
goto st0;
@@ -3154,7 +3162,7 @@ case 30:
if ( ++p == pe )
goto _test_eof31;
case 31:
-#line 3158 "src/ngx_http_memc_response.c"
+#line 3166 "src/ngx_http_memc_response.c"
if ( (*p) == 78 )
goto tr34;
goto st0;
@@ -3168,7 +3176,7 @@ case 31:
if ( ++p == pe )
goto _test_eof32;
case 32:
-#line 3172 "src/ngx_http_memc_response.c"
+#line 3180 "src/ngx_http_memc_response.c"
if ( (*p) == 68 )
goto tr35;
goto st0;
@@ -3182,7 +3190,7 @@ case 32:
if ( ++p == pe )
goto _test_eof33;
case 33:
-#line 3186 "src/ngx_http_memc_response.c"
+#line 3194 "src/ngx_http_memc_response.c"
if ( (*p) == 13 )
goto tr36;
goto st0;
@@ -3196,7 +3204,7 @@ case 33:
if ( ++p == pe )
goto _test_eof34;
case 34:
-#line 3200 "src/ngx_http_memc_response.c"
+#line 3208 "src/ngx_http_memc_response.c"
if ( (*p) == 10 )
goto tr37;
goto st0;
@@ -3210,7 +3218,7 @@ case 34:
if ( ++p == pe )
goto _test_eof35;
case 35:
-#line 3214 "src/ngx_http_memc_response.c"
+#line 3222 "src/ngx_http_memc_response.c"
if ( (*p) == 69 )
goto tr38;
goto st0;
@@ -3224,7 +3232,7 @@ case 35:
if ( ++p == pe )
goto _test_eof36;
case 36:
-#line 3228 "src/ngx_http_memc_response.c"
+#line 3236 "src/ngx_http_memc_response.c"
if ( (*p) == 82 )
goto tr39;
goto st0;
@@ -3238,7 +3246,7 @@ case 36:
if ( ++p == pe )
goto _test_eof37;
case 37:
-#line 3242 "src/ngx_http_memc_response.c"
+#line 3250 "src/ngx_http_memc_response.c"
if ( (*p) == 86 )
goto tr40;
goto st0;
@@ -3252,7 +3260,7 @@ case 37:
if ( ++p == pe )
goto _test_eof38;
case 38:
-#line 3256 "src/ngx_http_memc_response.c"
+#line 3264 "src/ngx_http_memc_response.c"
if ( (*p) == 69 )
goto tr41;
goto st0;
@@ -3266,7 +3274,7 @@ case 38:
if ( ++p == pe )
goto _test_eof39;
case 39:
-#line 3270 "src/ngx_http_memc_response.c"
+#line 3278 "src/ngx_http_memc_response.c"
if ( (*p) == 82 )
goto tr13;
goto st0;
@@ -3315,7 +3323,7 @@ case 39:
_out: {}
}
-#line 574 "src/ngx_http_memc_response.rl"
+#line 582 "src/ngx_http_memc_response.rl"
*cs_addr = cs;
View
8 src/ngx_http_memc_response.rl
@@ -342,6 +342,7 @@ ngx_http_memc_get_cmd_filter(void *data, ssize_t bytes)
ngx_int_t
ngx_http_memc_process_get_cmd_header(ngx_http_request_t *r)
{
+ ngx_http_memc_loc_conf_t *conf;
u_char *p, *len;
ngx_str_t line;
ngx_http_upstream_t *u;
@@ -412,6 +413,13 @@ found:
while (*p) {
if (*p++ == ' ') {
flags_vv->len = p - 1 - flags_vv->data;
+ conf = ngx_http_get_module_loc_conf(r, ngx_http_memc_module);
+
+ if (conf->flags_to_last_modified) {
+ r->headers_out.last_modified_time = ngx_atotm(flags_vv->data,
+ flags_vv->len);
+ }
+
goto length;
}
}
View
3 test/lib/Test/Nginx/LWP.pm
@@ -32,6 +32,7 @@ use Test::Nginx::Util qw(
master_process_enabled
config_preamble
repeat_each
+ no_shuffle
);
our $UserAgent = LWP::UserAgent->new;
@@ -43,7 +44,7 @@ $UserAgent->agent(__PACKAGE__);
our @EXPORT = qw( plan run_tests run_test
repeat_each config_preamble worker_connections
master_process_enabled
- no_long_string);
+ no_long_string no_shuffle);
sub no_long_string () {
$NoLongString = 1;
View
3 test/lib/Test/Nginx/Socket.pm
@@ -38,6 +38,7 @@ use Test::Nginx::Util qw(
workers
master_on
log_level
+ no_shuffle
);
#use Smart::Comments::JSON '###';
@@ -53,7 +54,7 @@ our @EXPORT = qw( plan run_tests run_test
repeat_each config_preamble worker_connections
master_process_enabled
no_long_string workers master_on
- log_level);
+ log_level no_shuffle);
sub send_request ($$$);
View
9 test/lib/Test/Nginx/Util.pm
@@ -20,6 +20,12 @@ our $Profiling = 0;
our $RepeatEach = 1;
our $MAX_PROCESSES = 10;
+our $NoShuffle = 0;
+
+sub no_shuffle () {
+ $NoShuffle = 1;
+}
+
our $ForkManager;
if ($Profiling) {
@@ -110,6 +116,7 @@ our @EXPORT_OK = qw(
repeat_each
master_process_enabled
log_level
+ no_shuffle
);
@@ -148,7 +155,7 @@ sub run_tests () {
#warn "[INFO] Using nginx version $NginxVersion ($NginxRawVersion)\n";
}
- for my $block (shuffle Test::Base::blocks()) {
+ for my $block ($NoShuffle ? Test::Base::blocks() : shuffle Test::Base::blocks()) {
#for (1..3) {
run_test($block);
#}
View
47 test/t/flags.t
@@ -3,9 +3,10 @@
use lib 'lib';
use Test::Nginx::LWP;
-plan tests => repeat_each() * 2 * blocks();
+plan tests => repeat_each() * 2 * blocks() + 4;
#no_diff;
+no_shuffle;
run_tests();
@@ -181,7 +182,7 @@ BAR"
-=== TEST 1: set flags and get flags in http time
+=== TEST 7: set flags and get flags in http time
--- config
location /flags {
echo 'set foo BAR (flag: 1264680563)';
@@ -211,3 +212,45 @@ status: 200
flags: 1264680563 Thu, 28 Jan 2010 12:09:23 GMT
BAR"
+
+
+=== TEST 8: last-modified (conditional GET)
+--- config
+ location /memc {
+ set $memc_key $arg_key;
+
+ memc_pass 127.0.0.1:11984;
+
+ memc_flags_to_last_modified on;
+ add_header X-Flags $memc_flags;
+ }
+--- request
+ GET /memc?key=foo
+--- request_headers
+If-Modified-Since: Thu, 28 Jan 2010 12:09:23 GMT
+--- response_headers
+Last-Modified: Thu, 28 Jan 2010 12:09:23 GMT
+X-Flags: 1264680563
+--- error_code: 304
+--- response_body:
+
+
+
+=== TEST 9: last-modified (unconditional GET)
+--- config
+ location /memc {
+ set $memc_key $arg_key;
+
+ memc_pass 127.0.0.1:11984;
+
+ memc_flags_to_last_modified on;
+ add_header X-Flags $memc_flags;
+ }
+--- request
+ GET /memc?key=foo
+--- response_headers
+Last-Modified: Thu, 28 Jan 2010 12:09:23 GMT
+X-Flags: 1264680563
+--- error_code: 200
+--- response_body: BAR
+

0 comments on commit 19875bb

Please sign in to comment.