comparison src/http/modules/ngx_http_memcached_module.c @ 320:1e9e2c5e7c14 NGINX_0_5_30

nginx 0.5.30 *) Feature: the $args variable can be set with the "set" directive. *) Feature: the $is_args variable. *) Bugfix: if a client has closed connection to mail proxy then nginx might not close connection to backend. *) Bugfix: now nginx escapes space in $memcached_key variable. *) Bugfix: a segmentation fault might occur in worker process when the HTTPS protocol was used in the "proxy_pass" directive. *) Bugfix: the perl $$ variable value in ngx_http_perl_module was equal to the master process identification number. *) Bugfix: fix building on Solaris/amd64 by Sun Studio 11 and early versions; bug appeared in 0.5.29.
author Igor Sysoev <http://sysoev.ru>
date Mon, 30 Jul 2007 00:00:00 +0400
parents 95d92ec39071
children f70f2f565fe0
comparison
equal deleted inserted replaced
319:10d5a311cc5e 320:1e9e2c5e7c14
224 224
225 static ngx_int_t 225 static ngx_int_t
226 ngx_http_memcached_create_request(ngx_http_request_t *r) 226 ngx_http_memcached_create_request(ngx_http_request_t *r)
227 { 227 {
228 size_t len; 228 size_t len;
229 uintptr_t escape;
229 ngx_buf_t *b; 230 ngx_buf_t *b;
230 ngx_chain_t *cl; 231 ngx_chain_t *cl;
231 ngx_http_memcached_ctx_t *ctx; 232 ngx_http_memcached_ctx_t *ctx;
232 ngx_http_variable_value_t *vv; 233 ngx_http_variable_value_t *vv;
233 ngx_http_memcached_loc_conf_t *mlcf; 234 ngx_http_memcached_loc_conf_t *mlcf;
240 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 241 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
241 "the \"$memcached_key\" variable is not set"); 242 "the \"$memcached_key\" variable is not set");
242 return NGX_ERROR; 243 return NGX_ERROR;
243 } 244 }
244 245
245 len = sizeof("get ") - 1 + vv->len + sizeof(CRLF) - 1; 246 escape = 2 * ngx_escape_uri(NULL, vv->data, vv->len, NGX_ESCAPE_MEMCACHED);
246 if (vv->len) { 247
247 len += 1 + vv->len; 248 len = sizeof("get ") - 1 + vv->len + escape + sizeof(CRLF) - 1;
248 }
249 249
250 b = ngx_create_temp_buf(r->pool, len); 250 b = ngx_create_temp_buf(r->pool, len);
251 if (b == NULL) { 251 if (b == NULL) {
252 return NGX_ERROR; 252 return NGX_ERROR;
253 } 253 }
266 266
267 ctx = ngx_http_get_module_ctx(r, ngx_http_memcached_module); 267 ctx = ngx_http_get_module_ctx(r, ngx_http_memcached_module);
268 268
269 ctx->key.data = b->last; 269 ctx->key.data = b->last;
270 270
271 b->last = ngx_copy(b->last, vv->data, vv->len); 271 if (escape == 0) {
272 b->last = ngx_copy(b->last, vv->data, vv->len);
273
274 } else {
275 b->last = (u_char *) ngx_escape_uri(b->last, vv->data, vv->len,
276 NGX_ESCAPE_MEMCACHED);
277 }
272 278
273 ctx->key.len = b->last - ctx->key.data; 279 ctx->key.len = b->last - ctx->key.data;
274 280
275 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 281 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
276 "http memcached request: \"%V\"", &ctx->key); 282 "http memcached request: \"%V\"", &ctx->key);