comparison src/http/modules/ngx_http_uwsgi_module.c @ 578:bc110f60c0de NGINX_0_8_41

nginx 0.8.41 *) Security: nginx/Windows worker might be terminated abnormally if a requested file name has invalid UTF-8 encoding. *) Change: now nginx allows to use spaces in a request line. *) Bugfix: the "proxy_redirect" directive changed incorrectly a backend "Refresh" response header line. Thanks to Andrey Andreew and Max Sogin. *) Bugfix: nginx did not support path without host name in "Destination" request header line.
author Igor Sysoev <http://sysoev.ru>
date Tue, 15 Jun 2010 00:00:00 +0400
parents 01f2313e34f1
children 4d3e880ce86c
comparison
equal deleted inserted replaced
577:dd4c3325a56f 578:bc110f60c0de
493 493
494 494
495 static ngx_int_t 495 static ngx_int_t
496 ngx_http_uwsgi_eval(ngx_http_request_t *r, ngx_http_uwsgi_loc_conf_t * uwcf) 496 ngx_http_uwsgi_eval(ngx_http_request_t *r, ngx_http_uwsgi_loc_conf_t * uwcf)
497 { 497 {
498 ngx_url_t u; 498 ngx_url_t url;
499 499 ngx_http_upstream_t *u;
500 ngx_memzero(&u, sizeof(ngx_url_t)); 500
501 501 ngx_memzero(&url, sizeof(ngx_url_t));
502 if (ngx_http_script_run(r, &u.url, uwcf->uwsgi_lengths->elts, 0, 502
503 if (ngx_http_script_run(r, &url.url, uwcf->uwsgi_lengths->elts, 0,
503 uwcf->uwsgi_values->elts) 504 uwcf->uwsgi_values->elts)
504 == NULL) 505 == NULL)
505 { 506 {
506 return NGX_ERROR; 507 return NGX_ERROR;
507 } 508 }
508 509
509 u.no_resolve = 1; 510 url.no_resolve = 1;
510 511
511 if (ngx_parse_url(r->pool, &u) != NGX_OK) { 512 if (ngx_parse_url(r->pool, &url) != NGX_OK) {
512 if (u.err) { 513 if (url.err) {
513 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 514 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
514 "%s in upstream \"%V\"", u.err, &u.url); 515 "%s in upstream \"%V\"", url.err, &url.url);
515 } 516 }
516 517
517 return NGX_ERROR; 518 return NGX_ERROR;
518 } 519 }
519 520
520 if (u.no_port) { 521 if (url.no_port) {
521 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 522 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
522 "no port in upstream \"%V\"", &u.url); 523 "no port in upstream \"%V\"", &url.url);
523 return NGX_ERROR; 524 return NGX_ERROR;
524 } 525 }
525 526
526 r->upstream->resolved = ngx_pcalloc(r->pool, 527 u = r->upstream;
527 sizeof(ngx_http_upstream_resolved_t)); 528
528 if (r->upstream->resolved == NULL) { 529 u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t));
530 if (u->resolved == NULL) {
529 return NGX_ERROR; 531 return NGX_ERROR;
530 } 532 }
531 533
532 if (u.addrs && u.addrs[0].sockaddr) { 534 if (url.addrs && url.addrs[0].sockaddr) {
533 r->upstream->resolved->sockaddr = u.addrs[0].sockaddr; 535 u->resolved->sockaddr = url.addrs[0].sockaddr;
534 r->upstream->resolved->socklen = u.addrs[0].socklen; 536 u->resolved->socklen = url.addrs[0].socklen;
535 r->upstream->resolved->naddrs = 1; 537 u->resolved->naddrs = 1;
536 r->upstream->resolved->host = u.addrs[0].name; 538 u->resolved->host = url.addrs[0].name;
537 539
538 } else { 540 } else {
539 r->upstream->resolved->host = u.host; 541 u->resolved->host = url.host;
540 r->upstream->resolved->port = u.port; 542 u->resolved->port = url.port;
541 } 543 }
542 544
543 return NGX_OK; 545 return NGX_OK;
544 } 546 }
545 547
828 cl = cl->next; 830 cl = cl->next;
829 cl->buf = b; 831 cl->buf = b;
830 832
831 body = body->next; 833 body = body->next;
832 } 834 }
833
834 b->flush = 1;
835 835
836 } else { 836 } else {
837 r->upstream->request_bufs = cl; 837 r->upstream->request_bufs = cl;
838 } 838 }
839 839
1197 /* a whole header has been parsed successfully */ 1197 /* a whole header has been parsed successfully */
1198 1198
1199 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1199 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1200 "http uwsgi header done"); 1200 "http uwsgi header done");
1201 1201
1202 /*
1203 * if no "Server" and "Date" in header line,
1204 * then add the special empty headers
1205 */
1206
1207 if (r->upstream->headers_in.server == NULL) {
1208 h = ngx_list_push(&r->upstream->headers_in.headers);
1209 if (h == NULL) {
1210 return NGX_ERROR;
1211 }
1212
1213 h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash(
1214 ngx_hash ('s', 'e'), 'r'), 'v'), 'e'), 'r');
1215
1216 ngx_str_set(&h->key, "Server");
1217 ngx_str_null(&h->value);
1218 h->lowcase_key = (u_char *) "server";
1219 }
1220
1221 if (r->upstream->headers_in.date == NULL) {
1222 h = ngx_list_push(&r->upstream->headers_in.headers);
1223 if (h == NULL) {
1224 return NGX_ERROR;
1225 }
1226
1227 h->hash = ngx_hash(ngx_hash(ngx_hash('d', 'a'), 't'), 'e');
1228
1229 ngx_str_set(&h->key, "Date");
1230 ngx_str_null(&h->value);
1231 h->lowcase_key = (u_char *) "date";
1232 }
1233
1234 return NGX_OK; 1202 return NGX_OK;
1235 } 1203 }
1236 1204
1237 if (rc == NGX_AGAIN) { 1205 if (rc == NGX_AGAIN) {
1238 return NGX_AGAIN; 1206 return NGX_AGAIN;