support CGI-style response

This commit is contained in:
Igor Sysoev 2010-06-15 14:30:13 +00:00
parent 68294d776d
commit 85fe9bf6b1

View File

@ -1100,10 +1100,10 @@ ngx_http_uwsgi_process_status_line(ngx_http_request_t *r)
"upstream sent no valid HTTP/1.0 header");
r->http_version = NGX_HTTP_VERSION_9;
u->headers_in.status_n = NGX_HTTP_OK;
u->state->status = NGX_HTTP_OK;
return NGX_OK;
u->process_header = ngx_http_uwsgi_process_header;
return ngx_http_uwsgi_process_header(r);
}
if (u->state) {
@ -1135,8 +1135,10 @@ ngx_http_uwsgi_process_status_line(ngx_http_request_t *r)
static ngx_int_t
ngx_http_uwsgi_process_header(ngx_http_request_t *r)
{
ngx_int_t rc;
ngx_str_t *status_line;
ngx_int_t rc, status;
ngx_table_elt_t *h;
ngx_http_upstream_t *u;
ngx_http_upstream_header_t *hh;
ngx_http_upstream_main_conf_t *umcf;
@ -1200,6 +1202,45 @@ ngx_http_uwsgi_process_header(ngx_http_request_t *r)
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http uwsgi header done");
if (r->http_version > NGX_HTTP_VERSION_9) {
return NGX_OK;
}
u = r->upstream;
if (u->headers_in.status) {
status_line = &u->headers_in.status->value;
status = ngx_atoi(status_line->data, 3);
if (status == NGX_ERROR) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"upstream sent invalid status \"%V\"",
status_line);
return NGX_HTTP_UPSTREAM_INVALID_HEADER;
}
r->http_version = NGX_HTTP_VERSION_10;
u->headers_in.status_n = status;
u->headers_in.status_line = *status_line;
} else if (u->headers_in.location) {
r->http_version = NGX_HTTP_VERSION_10;
u->headers_in.status_n = 302;
ngx_str_set(&u->headers_in.status_line,
"302 Moved Temporarily");
} else {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"upstream sent neither valid HTTP/1.0 header "
"nor \"Status\" header line");
u->headers_in.status_n = 200;
ngx_str_set(&u->headers_in.status_line, "200 OK");
}
if (u->state) {
u->state->status = u->headers_in.status_n;
}
return NGX_OK;
}