comparison src/http/modules/ngx_http_uwsgi_module.c @ 3624:3b7e8fa31a00

support CGI-style response
author Igor Sysoev <igor@sysoev.ru>
date Tue, 15 Jun 2010 14:30:13 +0000
parents 633ef29c9881
children 8a6b36db2398
comparison
equal deleted inserted replaced
3623:633ef29c9881 3624:3b7e8fa31a00
1098 1098
1099 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 1099 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1100 "upstream sent no valid HTTP/1.0 header"); 1100 "upstream sent no valid HTTP/1.0 header");
1101 1101
1102 r->http_version = NGX_HTTP_VERSION_9; 1102 r->http_version = NGX_HTTP_VERSION_9;
1103 u->headers_in.status_n = NGX_HTTP_OK; 1103
1104 u->state->status = NGX_HTTP_OK; 1104 u->process_header = ngx_http_uwsgi_process_header;
1105 1105
1106 return NGX_OK; 1106 return ngx_http_uwsgi_process_header(r);
1107 } 1107 }
1108 1108
1109 if (u->state) { 1109 if (u->state) {
1110 u->state->status = ctx->status; 1110 u->state->status = ctx->status;
1111 } 1111 }
1133 1133
1134 1134
1135 static ngx_int_t 1135 static ngx_int_t
1136 ngx_http_uwsgi_process_header(ngx_http_request_t *r) 1136 ngx_http_uwsgi_process_header(ngx_http_request_t *r)
1137 { 1137 {
1138 ngx_int_t rc; 1138 ngx_str_t *status_line;
1139 ngx_int_t rc, status;
1139 ngx_table_elt_t *h; 1140 ngx_table_elt_t *h;
1141 ngx_http_upstream_t *u;
1140 ngx_http_upstream_header_t *hh; 1142 ngx_http_upstream_header_t *hh;
1141 ngx_http_upstream_main_conf_t *umcf; 1143 ngx_http_upstream_main_conf_t *umcf;
1142 1144
1143 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); 1145 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
1144 1146
1197 1199
1198 /* a whole header has been parsed successfully */ 1200 /* a whole header has been parsed successfully */
1199 1201
1200 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1202 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1201 "http uwsgi header done"); 1203 "http uwsgi header done");
1204
1205 if (r->http_version > NGX_HTTP_VERSION_9) {
1206 return NGX_OK;
1207 }
1208
1209 u = r->upstream;
1210
1211 if (u->headers_in.status) {
1212 status_line = &u->headers_in.status->value;
1213
1214 status = ngx_atoi(status_line->data, 3);
1215 if (status == NGX_ERROR) {
1216 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1217 "upstream sent invalid status \"%V\"",
1218 status_line);
1219 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
1220 }
1221
1222 r->http_version = NGX_HTTP_VERSION_10;
1223 u->headers_in.status_n = status;
1224 u->headers_in.status_line = *status_line;
1225
1226 } else if (u->headers_in.location) {
1227 r->http_version = NGX_HTTP_VERSION_10;
1228 u->headers_in.status_n = 302;
1229 ngx_str_set(&u->headers_in.status_line,
1230 "302 Moved Temporarily");
1231
1232 } else {
1233 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1234 "upstream sent neither valid HTTP/1.0 header "
1235 "nor \"Status\" header line");
1236 u->headers_in.status_n = 200;
1237 ngx_str_set(&u->headers_in.status_line, "200 OK");
1238 }
1239
1240 if (u->state) {
1241 u->state->status = u->headers_in.status_n;
1242 }
1202 1243
1203 return NGX_OK; 1244 return NGX_OK;
1204 } 1245 }
1205 1246
1206 if (rc == NGX_AGAIN) { 1247 if (rc == NGX_AGAIN) {