Mercurial > hg > nginx-quic
comparison src/http/ngx_http_request_body.c @ 292:a472bfb778b3
nginx-0.0.3-2004-03-17-00:26:01 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 16 Mar 2004 21:26:01 +0000 |
parents | 87e73f067470 |
children | ec3c049681fd |
comparison
equal
deleted
inserted
replaced
291:117ccc7c4055 | 292:a472bfb778b3 |
---|---|
81 ngx_http_core_loc_conf_t *clcf; | 81 ngx_http_core_loc_conf_t *clcf; |
82 | 82 |
83 c = rev->data; | 83 c = rev->data; |
84 r = c->data; | 84 r = c->data; |
85 | 85 |
86 if (r->request_body_hunk->end - r->request_body_hunk->last == 0) { | 86 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
87 n = ngx_write_chain_to_temp_file(r->temp_file, | 87 "http read client request body"); |
88 | |
89 for ( ;; ) { | |
90 if (r->request_body_hunk->last == r->request_body_hunk->end) { | |
91 n = ngx_write_chain_to_temp_file(r->temp_file, | |
88 r->request_hunks->next ? r->request_hunks->next: | 92 r->request_hunks->next ? r->request_hunks->next: |
89 r->request_hunks); | 93 r->request_hunks); |
90 /* TODO: n == 0 or not complete and level event */ | |
91 | 94 |
92 if (n == NGX_ERROR) { | 95 /* TODO: n == 0 or not complete and level event */ |
93 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 96 |
97 if (n == NGX_ERROR) { | |
98 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
99 return; | |
100 } | |
101 | |
102 r->temp_file->offset += n; | |
103 | |
104 r->request_body_hunk->pos = r->request_body_hunk->start; | |
105 r->request_body_hunk->last = r->request_body_hunk->start; | |
106 } | |
107 | |
108 size = r->request_body_hunk->end - r->request_body_hunk->last; | |
109 | |
110 if (size > r->request_body_len) { | |
111 size = r->request_body_len; | |
112 } | |
113 | |
114 n = ngx_recv(c, r->request_body_hunk->last, size); | |
115 | |
116 if (n == NGX_AGAIN) { | |
117 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
118 ngx_add_timer(rev, clcf->client_body_timeout); | |
119 | |
120 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { | |
121 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
122 } | |
123 | |
94 return; | 124 return; |
95 } | 125 } |
96 | 126 |
97 r->temp_file->offset += n; | 127 if (n == 0) { |
98 | 128 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
99 r->request_body_hunk->pos = r->request_body_hunk->start; | 129 "client closed prematurely connection"); |
100 r->request_body_hunk->last = r->request_body_hunk->start; | |
101 } | |
102 | |
103 size = r->request_body_hunk->end - r->request_body_hunk->last; | |
104 | |
105 if (size > r->request_body_len) { | |
106 size = r->request_body_len; | |
107 } | |
108 | |
109 n = ngx_recv(c, r->request_body_hunk->last, size); | |
110 | |
111 if (n == NGX_AGAIN) { | |
112 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
113 ngx_add_timer(rev, clcf->client_body_timeout); | |
114 | |
115 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { | |
116 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
117 } | 130 } |
118 | 131 |
119 return; | 132 if (n == 0 || n == NGX_ERROR) { |
133 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
134 return; | |
135 } | |
136 | |
137 r->request_body_hunk->last += n; | |
138 r->request_body_len -= n; | |
139 | |
140 if (r->request_body_hunk->last < r->request_body_hunk->end) { | |
141 break; | |
142 } | |
120 } | 143 } |
121 | |
122 if (n == 0) { | |
123 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
124 "client closed prematurely connection"); | |
125 } | |
126 | |
127 if (n == 0 || n == NGX_ERROR) { | |
128 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
129 return; | |
130 } | |
131 | |
132 r->request_body_hunk->last += n; | |
133 r->request_body_len -= n; | |
134 | 144 |
135 if (r->request_body_len) { | 145 if (r->request_body_len) { |
136 return; | 146 return; |
137 } | 147 } |
138 | 148 |
140 | 150 |
141 /* save the last part */ | 151 /* save the last part */ |
142 n = ngx_write_chain_to_temp_file(r->temp_file, | 152 n = ngx_write_chain_to_temp_file(r->temp_file, |
143 r->request_hunks->next ? r->request_hunks->next: | 153 r->request_hunks->next ? r->request_hunks->next: |
144 r->request_hunks); | 154 r->request_hunks); |
155 | |
145 /* TODO: n == 0 or not complete and level event */ | 156 /* TODO: n == 0 or not complete and level event */ |
146 | 157 |
147 if (n == NGX_ERROR) { | 158 if (n == NGX_ERROR) { |
148 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 159 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
149 return; | 160 return; |