comparison src/http/modules/ngx_http_memcached_module.c @ 322:d16d691432c9 NGINX_0_6_5

nginx 0.6.5 *) Feature: $nginx_version variable. Thanks to Nick S. Grechukh. *) Feature: the mail proxy supports AUTHENTICATE in IMAP mode. Thanks to Maxim Dounin. *) Feature: the mail proxy supports STARTTLS in SMTP mode. Thanks to Maxim Dounin. *) Bugfix: now nginx escapes space in $memcached_key variable. *) Bugfix: nginx was incorrectly built by Sun Studio on Solaris/amd64. Thanks to Jiang Hong. *) Bugfix: of minor potential bugs. Thanks to Coverity's Scan.
author Igor Sysoev <http://sysoev.ru>
date Mon, 23 Jul 2007 00:00:00 +0400
parents 95d92ec39071
children 9fc4ab6673f9
comparison
equal deleted inserted replaced
321:a87830ef6fdd 322:d16d691432c9
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);