Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_fastcgi_module.c @ 615:5ef026a2ac74 release-0.3.29
nginx-0.3.29-RELEASE import
*) Feature: now nginx uses less memory, if PHP in FastCGI mode sends
many warnings before the response.
*) Bugfix: the "Transfer-Encoding: chunked" header line was issued in
the 204 responses for the HTTP/1.1 requests.
*) Bugfix: nginx returned the 502 response, if the complete response
header lines were transferred in a separate FastCGI records.
*) Bugfix: if the proxied URI was specified in the "post_action"
directive, then it ran only after a successful completion of a
request.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 20 Feb 2006 16:48:17 +0000 |
parents | 4e296b7d25bf |
children | 7a16e281c01f |
comparison
equal
deleted
inserted
replaced
614:790c134e002d | 615:5ef026a2ac74 |
---|---|
44 u_char *last; | 44 u_char *last; |
45 ngx_uint_t type; | 45 ngx_uint_t type; |
46 size_t length; | 46 size_t length; |
47 size_t padding; | 47 size_t padding; |
48 | 48 |
49 ngx_uint_t header; | 49 ngx_uint_t fastcgi_stdout; |
50 } ngx_http_fastcgi_ctx_t; | 50 } ngx_http_fastcgi_ctx_t; |
51 | 51 |
52 | 52 |
53 #define NGX_HTTP_FASTCGI_RESPONDER 1 | 53 #define NGX_HTTP_FASTCGI_RESPONDER 1 |
54 | 54 |
774 if (f == NULL) { | 774 if (f == NULL) { |
775 return NGX_OK; | 775 return NGX_OK; |
776 } | 776 } |
777 | 777 |
778 f->state = ngx_http_fastcgi_st_version; | 778 f->state = ngx_http_fastcgi_st_version; |
779 f->header = 0; | 779 f->fastcgi_stdout = 0; |
780 | 780 |
781 return NGX_OK; | 781 return NGX_OK; |
782 } | 782 } |
783 | 783 |
784 | 784 |
874 | 874 |
875 /* f->state == ngx_http_fastcgi_st_data */ | 875 /* f->state == ngx_http_fastcgi_st_data */ |
876 | 876 |
877 if (f->type == NGX_HTTP_FASTCGI_STDERR) { | 877 if (f->type == NGX_HTTP_FASTCGI_STDERR) { |
878 | 878 |
879 if (f->header) { | |
880 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
881 "upstream split a header in FastCGI records"); | |
882 | |
883 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
884 } | |
885 | |
886 if (f->length) { | 879 if (f->length) { |
887 line.data = u->buffer.pos; | 880 line.data = u->buffer.pos; |
888 | 881 |
889 if (u->buffer.pos + f->length <= u->buffer.last) { | 882 if (u->buffer.pos + f->length <= u->buffer.last) { |
890 line.len = f->length; | 883 line.len = f->length; |
908 | 901 |
909 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | 902 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
910 "FastCGI sent in stderr: \"%V\"", &line); | 903 "FastCGI sent in stderr: \"%V\"", &line); |
911 | 904 |
912 if (u->buffer.pos == u->buffer.last) { | 905 if (u->buffer.pos == u->buffer.last) { |
906 | |
907 if (!f->fastcgi_stdout) { | |
908 | |
909 /* | |
910 * the special handling the large number | |
911 * of the PHP warnings to not allocate memory | |
912 */ | |
913 | |
914 u->buffer.pos = u->buffer.start; | |
915 u->buffer.last = u->buffer.start; | |
916 } | |
917 | |
913 return NGX_AGAIN; | 918 return NGX_AGAIN; |
914 } | 919 } |
915 | 920 |
916 } else { | 921 } else { |
917 f->state = ngx_http_fastcgi_st_version; | 922 f->state = ngx_http_fastcgi_st_version; |
920 continue; | 925 continue; |
921 } | 926 } |
922 | 927 |
923 | 928 |
924 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ | 929 /* f->type == NGX_HTTP_FASTCGI_STDOUT */ |
930 | |
931 f->fastcgi_stdout = 1; | |
925 | 932 |
926 start = u->buffer.pos; | 933 start = u->buffer.pos; |
927 | 934 |
928 if (u->buffer.pos + f->length < u->buffer.last) { | 935 if (u->buffer.pos + f->length < u->buffer.last) { |
929 | 936 |
936 u->buffer.last = u->buffer.pos + f->length; | 943 u->buffer.last = u->buffer.pos + f->length; |
937 | 944 |
938 } else { | 945 } else { |
939 last = NULL; | 946 last = NULL; |
940 } | 947 } |
941 | |
942 f->header = 1; | |
943 | 948 |
944 for ( ;; ) { | 949 for ( ;; ) { |
945 | 950 |
946 rc = ngx_http_parse_header_line(r, &u->buffer); | 951 rc = ngx_http_parse_header_line(r, &u->buffer); |
947 | 952 |
989 | 994 |
990 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 995 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
991 "http fastcgi header: \"%V: %V\"", | 996 "http fastcgi header: \"%V: %V\"", |
992 &h->key, &h->value); | 997 &h->key, &h->value); |
993 | 998 |
994 continue; | 999 if (u->buffer.pos < u->buffer.last) { |
1000 continue; | |
1001 } | |
1002 | |
1003 /* the end of the FastCGI record */ | |
1004 | |
1005 break; | |
995 } | 1006 } |
996 | 1007 |
997 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | 1008 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { |
998 | 1009 |
999 /* a whole header has been parsed successfully */ | 1010 /* a whole header has been parsed successfully */ |
1042 if (last) { | 1053 if (last) { |
1043 u->buffer.last = last; | 1054 u->buffer.last = last; |
1044 } | 1055 } |
1045 | 1056 |
1046 f->length -= u->buffer.pos - start; | 1057 f->length -= u->buffer.pos - start; |
1047 | |
1048 if (rc == NGX_AGAIN) { | |
1049 if (u->buffer.pos == u->buffer.last) { | |
1050 return NGX_AGAIN; | |
1051 } | |
1052 | |
1053 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
1054 "upstream split a header in FastCGI records"); | |
1055 | |
1056 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1057 } | |
1058 | 1058 |
1059 if (f->length == 0) { | 1059 if (f->length == 0) { |
1060 if (f->padding) { | 1060 if (f->padding) { |
1061 f->state = ngx_http_fastcgi_st_padding; | 1061 f->state = ngx_http_fastcgi_st_padding; |
1062 } else { | 1062 } else { |
1063 f->state = ngx_http_fastcgi_st_version; | 1063 f->state = ngx_http_fastcgi_st_version; |
1064 } | 1064 } |
1065 } | 1065 } |
1066 | 1066 |
1067 return NGX_OK; | 1067 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { |
1068 return NGX_OK; | |
1069 } | |
1070 | |
1071 if (u->buffer.pos == u->buffer.last) { | |
1072 return NGX_AGAIN; | |
1073 } | |
1074 | |
1075 if (rc == NGX_AGAIN) { | |
1076 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
1077 "upstream split a header line in FastCGI records"); | |
1078 | |
1079 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1080 } | |
1068 } | 1081 } |
1069 } | 1082 } |
1070 | 1083 |
1071 | 1084 |
1072 static ngx_int_t | 1085 static ngx_int_t |