comparison src/http/modules/ngx_http_scgi_module.c @ 4371:16ebad9447ee

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 19 Dec 2011 11:23:16 +0000
parents 059260de158d
children b228587a6494
comparison
equal deleted inserted replaced
4370:88aa90a198dd 4371:16ebad9447ee
855 if (rc == NGX_AGAIN) { 855 if (rc == NGX_AGAIN) {
856 return rc; 856 return rc;
857 } 857 }
858 858
859 if (rc == NGX_ERROR) { 859 if (rc == NGX_ERROR) {
860
861 r->http_version = NGX_HTTP_VERSION_9;
862
863 u->process_header = ngx_http_scgi_process_header; 860 u->process_header = ngx_http_scgi_process_header;
864
865 return ngx_http_scgi_process_header(r); 861 return ngx_http_scgi_process_header(r);
866 } 862 }
867 863
868 if (u->state) { 864 if (u->state) {
869 u->state->status = status->code; 865 u->state->status = status->code;
959 /* a whole header has been parsed successfully */ 955 /* a whole header has been parsed successfully */
960 956
961 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 957 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
962 "http scgi header done"); 958 "http scgi header done");
963 959
964 if (r->http_version > NGX_HTTP_VERSION_9) { 960 u = r->upstream;
961
962 if (u->headers_in.status_n) {
965 return NGX_OK; 963 return NGX_OK;
966 } 964 }
967
968 u = r->upstream;
969 965
970 if (u->headers_in.status) { 966 if (u->headers_in.status) {
971 status_line = &u->headers_in.status->value; 967 status_line = &u->headers_in.status->value;
972 968
973 status = ngx_atoi(status_line->data, 3); 969 status = ngx_atoi(status_line->data, 3);
976 "upstream sent invalid status \"%V\"", 972 "upstream sent invalid status \"%V\"",
977 status_line); 973 status_line);
978 return NGX_HTTP_UPSTREAM_INVALID_HEADER; 974 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
979 } 975 }
980 976
981 r->http_version = NGX_HTTP_VERSION_10;
982 u->headers_in.status_n = status; 977 u->headers_in.status_n = status;
983 u->headers_in.status_line = *status_line; 978 u->headers_in.status_line = *status_line;
984 979
985 } else if (u->headers_in.location) { 980 } else if (u->headers_in.location) {
986 r->http_version = NGX_HTTP_VERSION_10;
987 u->headers_in.status_n = 302; 981 u->headers_in.status_n = 302;
988 ngx_str_set(&u->headers_in.status_line, 982 ngx_str_set(&u->headers_in.status_line,
989 "302 Moved Temporarily"); 983 "302 Moved Temporarily");
990 984
991 } else { 985 } else {