Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_scgi_module.c @ 4437:3a1507f48686 stable-1.0
Merge of r4372, r4373, r4374:
SCGI fixes:
*) Fixed incorrect use of r->http_version in scgi module.
The r->http_version is a version of client's request, and modules
must not set it unless they are really willing to downgrade protocol
version used for a response (i.e. to HTTP/0.9 if no response headers
are available). In neither case r->http_version may be upgraded.
The former code downgraded response from HTTP/1.1 to HTTP/1.0 for no
reason, causing various problems (see ticket #66). It was also
possible that HTTP/0.9 requests were upgraded to HTTP/1.0.
*) Removed duplicate function declaration.
*) Removed error if there is no Status header.
The SCGI specification doesn't specify format of the response, and
assuming CGI specs should be used there is no reason to complain.
RFC 3875 explicitly states that "A Status header field is optional,
and status 200 'OK' is assumed if it is omitted".
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 05 Feb 2012 13:53:50 +0000 |
parents | 8e7bb000ba4a |
children | 2b2d51cdbd97 |
comparison
equal
deleted
inserted
replaced
4436:311b358658c8 | 4437:3a1507f48686 |
---|---|
33 static ngx_int_t ngx_http_scgi_eval(ngx_http_request_t *r, | 33 static ngx_int_t ngx_http_scgi_eval(ngx_http_request_t *r, |
34 ngx_http_scgi_loc_conf_t *scf); | 34 ngx_http_scgi_loc_conf_t *scf); |
35 static ngx_int_t ngx_http_scgi_create_request(ngx_http_request_t *r); | 35 static ngx_int_t ngx_http_scgi_create_request(ngx_http_request_t *r); |
36 static ngx_int_t ngx_http_scgi_reinit_request(ngx_http_request_t *r); | 36 static ngx_int_t ngx_http_scgi_reinit_request(ngx_http_request_t *r); |
37 static ngx_int_t ngx_http_scgi_process_status_line(ngx_http_request_t *r); | 37 static ngx_int_t ngx_http_scgi_process_status_line(ngx_http_request_t *r); |
38 static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r); | |
39 static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r); | 38 static ngx_int_t ngx_http_scgi_process_header(ngx_http_request_t *r); |
40 static void ngx_http_scgi_abort_request(ngx_http_request_t *r); | 39 static void ngx_http_scgi_abort_request(ngx_http_request_t *r); |
41 static void ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc); | 40 static void ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc); |
42 | 41 |
43 static void *ngx_http_scgi_create_loc_conf(ngx_conf_t *cf); | 42 static void *ngx_http_scgi_create_loc_conf(ngx_conf_t *cf); |
822 if (rc == NGX_AGAIN) { | 821 if (rc == NGX_AGAIN) { |
823 return rc; | 822 return rc; |
824 } | 823 } |
825 | 824 |
826 if (rc == NGX_ERROR) { | 825 if (rc == NGX_ERROR) { |
827 | |
828 r->http_version = NGX_HTTP_VERSION_9; | |
829 | |
830 u->process_header = ngx_http_scgi_process_header; | 826 u->process_header = ngx_http_scgi_process_header; |
831 | |
832 return ngx_http_scgi_process_header(r); | 827 return ngx_http_scgi_process_header(r); |
833 } | 828 } |
834 | 829 |
835 if (u->state) { | 830 if (u->state) { |
836 u->state->status = status->code; | 831 u->state->status = status->code; |
926 /* a whole header has been parsed successfully */ | 921 /* a whole header has been parsed successfully */ |
927 | 922 |
928 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 923 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
929 "http scgi header done"); | 924 "http scgi header done"); |
930 | 925 |
931 if (r->http_version > NGX_HTTP_VERSION_9) { | 926 u = r->upstream; |
927 | |
928 if (u->headers_in.status_n) { | |
932 return NGX_OK; | 929 return NGX_OK; |
933 } | 930 } |
934 | |
935 u = r->upstream; | |
936 | 931 |
937 if (u->headers_in.status) { | 932 if (u->headers_in.status) { |
938 status_line = &u->headers_in.status->value; | 933 status_line = &u->headers_in.status->value; |
939 | 934 |
940 status = ngx_atoi(status_line->data, 3); | 935 status = ngx_atoi(status_line->data, 3); |
943 "upstream sent invalid status \"%V\"", | 938 "upstream sent invalid status \"%V\"", |
944 status_line); | 939 status_line); |
945 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | 940 return NGX_HTTP_UPSTREAM_INVALID_HEADER; |
946 } | 941 } |
947 | 942 |
948 r->http_version = NGX_HTTP_VERSION_10; | |
949 u->headers_in.status_n = status; | 943 u->headers_in.status_n = status; |
950 u->headers_in.status_line = *status_line; | 944 u->headers_in.status_line = *status_line; |
951 | 945 |
952 } else if (u->headers_in.location) { | 946 } else if (u->headers_in.location) { |
953 r->http_version = NGX_HTTP_VERSION_10; | |
954 u->headers_in.status_n = 302; | 947 u->headers_in.status_n = 302; |
955 ngx_str_set(&u->headers_in.status_line, | 948 ngx_str_set(&u->headers_in.status_line, |
956 "302 Moved Temporarily"); | 949 "302 Moved Temporarily"); |
957 | 950 |
958 } else { | 951 } else { |
959 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
960 "upstream sent neither valid HTTP/1.0 header " | |
961 "nor \"Status\" header line"); | |
962 u->headers_in.status_n = 200; | 952 u->headers_in.status_n = 200; |
963 ngx_str_set(&u->headers_in.status_line, "200 OK"); | 953 ngx_str_set(&u->headers_in.status_line, "200 OK"); |
964 } | 954 } |
965 | 955 |
966 if (u->state) { | 956 if (u->state) { |