Mercurial > hg > nginx-mail
comparison src/http/ngx_http_request_body.c @ 50:72eb30262aac NGINX_0_1_25
nginx 0.1.25
*) Bugfix: nginx did run on Linux parisc.
*) Feature: nginx now does not start under FreeBSD if the sysctl
kern.ipc.somaxconn value is too big.
*) Bugfix: if a request was internally redirected by the
ngx_http_index_module module to the ngx_http_proxy_module or
ngx_http_fastcgi_module modules, then the index file was not closed
after request completion.
*) Feature: the "proxy_pass" can be used in location with regular
expression.
*) Feature: the ngx_http_rewrite_filter_module module supports the
condition like "if ($HTTP_USER_AGENT ~ MSIE)".
*) Bugfix: nginx started too slow if the large number of addresses and
text values were used in the "geo" directive.
*) Change: a variable name must be declared as "$name" in the "geo"
directive. The previous variant without "$" is still supported, but
will be removed soon.
*) Feature: the "%{VARIABLE}v" logging parameter.
*) Feature: the "set $name value" directive.
*) Bugfix: gcc 4.0 compatibility.
*) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Sat, 19 Mar 2005 00:00:00 +0300 |
parents | 7ca9bdc82b3f |
children | b55cbf18157e |
comparison
equal
deleted
inserted
replaced
49:93dabbc9efb9 | 50:72eb30262aac |
---|---|
10 #include <ngx_http.h> | 10 #include <ngx_http.h> |
11 | 11 |
12 | 12 |
13 static void ngx_http_read_client_request_body_handler(ngx_event_t *rev); | 13 static void ngx_http_read_client_request_body_handler(ngx_event_t *rev); |
14 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r, | 14 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r, |
15 ngx_connection_t *c); | 15 ngx_connection_t *c); |
16 | 16 |
17 /* | 17 /* |
18 * on completion ngx_http_read_client_request_body() adds to | 18 * on completion ngx_http_read_client_request_body() adds to |
19 * r->request_body->bufs one or two bufs: | 19 * r->request_body->bufs one or two bufs: |
20 * *) one memory buf that was preread in r->header_in; | 20 * *) one memory buf that was preread in r->header_in; |
21 * *) one memory or file buf that contains the rest of the body | 21 * *) one memory or file buf that contains the rest of the body |
22 */ | 22 */ |
23 | 23 |
24 ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r, | 24 ngx_int_t |
25 ngx_http_client_body_handler_pt post_handler) | 25 ngx_http_read_client_request_body(ngx_http_request_t *r, |
26 ngx_http_client_body_handler_pt post_handler) | |
26 | 27 |
27 { | 28 { |
28 ssize_t size; | 29 ssize_t size; |
29 ngx_buf_t *b; | 30 ngx_buf_t *b; |
30 ngx_chain_t *cl; | 31 ngx_chain_t *cl; |
32 ngx_connection_t *c; | |
31 ngx_http_request_body_t *rb; | 33 ngx_http_request_body_t *rb; |
32 ngx_http_core_loc_conf_t *clcf; | 34 ngx_http_core_loc_conf_t *clcf; |
33 | 35 |
34 if (!(rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t)))) { | 36 rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t)); |
37 if (rb == NULL) { | |
35 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 38 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
36 } | 39 } |
37 | 40 |
38 r->request_body = rb; | 41 r->request_body = rb; |
42 | |
43 /* STUB */ | |
44 if (r->file.fd != NGX_INVALID_FILE) { | |
45 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) { | |
46 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, | |
47 ngx_close_file_n " \"%V\" failed", &r->file.name); | |
48 } | |
49 r->file.fd = NGX_INVALID_FILE; | |
50 } | |
51 /**/ | |
39 | 52 |
40 if (r->headers_in.content_length_n <= 0) { | 53 if (r->headers_in.content_length_n <= 0) { |
41 post_handler(r); | 54 post_handler(r); |
42 return NGX_OK; | 55 return NGX_OK; |
43 } | 56 } |
56 | 69 |
57 if (size) { | 70 if (size) { |
58 | 71 |
59 /* there is the pre-read part of the request body */ | 72 /* there is the pre-read part of the request body */ |
60 | 73 |
61 if (!(b = ngx_calloc_buf(r->pool))) { | 74 b = ngx_calloc_buf(r->pool); |
75 if (b == NULL) { | |
62 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 76 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
63 } | 77 } |
64 | 78 |
65 b->temporary = 1; | 79 b->temporary = 1; |
66 b->start = b->pos = r->header_in->pos; | 80 b->start = b->pos = r->header_in->pos; |
67 b->end = b->last = r->header_in->last; | 81 b->end = b->last = r->header_in->last; |
68 | 82 |
69 if (!(rb->bufs = ngx_alloc_chain_link(r->pool))) { | 83 rb->bufs = ngx_alloc_chain_link(r->pool); |
84 if (rb->bufs == NULL) { | |
70 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 85 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
71 } | 86 } |
72 | 87 |
73 rb->bufs->buf = b; | 88 rb->bufs->buf = b; |
74 rb->bufs->next = NULL; | 89 rb->bufs->next = NULL; |
101 | 116 |
102 } else { | 117 } else { |
103 size = clcf->client_body_buffer_size; | 118 size = clcf->client_body_buffer_size; |
104 } | 119 } |
105 | 120 |
106 if (!(rb->buf = ngx_create_temp_buf(r->pool, size))) { | 121 rb->buf = ngx_create_temp_buf(r->pool, size); |
122 if (rb->buf == NULL) { | |
107 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 123 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
108 } | 124 } |
109 | 125 |
110 if (!(cl = ngx_alloc_chain_link(r->pool))) { | 126 cl = ngx_alloc_chain_link(r->pool); |
127 if (cl == NULL) { | |
111 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 128 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
112 } | 129 } |
113 | 130 |
114 cl->buf = rb->buf; | 131 cl->buf = rb->buf; |
115 cl->next = NULL; | 132 cl->next = NULL; |
119 | 136 |
120 } else { | 137 } else { |
121 rb->bufs = cl; | 138 rb->bufs = cl; |
122 } | 139 } |
123 | 140 |
124 r->connection->read->event_handler = | 141 c = r->connection; |
125 ngx_http_read_client_request_body_handler; | 142 |
126 | 143 c->read->event_handler = ngx_http_read_client_request_body_handler; |
127 return ngx_http_do_read_client_request_body(r, r->connection); | 144 |
145 return ngx_http_do_read_client_request_body(r, c); | |
128 } | 146 } |
129 | 147 |
130 | 148 |
131 static void ngx_http_read_client_request_body_handler(ngx_event_t *rev) | 149 static void |
150 ngx_http_read_client_request_body_handler(ngx_event_t *rev) | |
132 { | 151 { |
133 ngx_int_t rc; | 152 ngx_int_t rc; |
134 ngx_connection_t *c; | 153 ngx_connection_t *c; |
135 ngx_http_request_t *r; | 154 ngx_http_request_t *r; |
136 | 155 |
148 ngx_http_finalize_request(r, rc); | 167 ngx_http_finalize_request(r, rc); |
149 } | 168 } |
150 } | 169 } |
151 | 170 |
152 | 171 |
153 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r, | 172 static ngx_int_t |
154 ngx_connection_t *c) | 173 ngx_http_do_read_client_request_body(ngx_http_request_t *r, |
174 ngx_connection_t *c) | |
155 { | 175 { |
156 size_t size; | 176 size_t size; |
157 ssize_t n; | 177 ssize_t n; |
158 ngx_buf_t *b; | 178 ngx_buf_t *b; |
159 ngx_temp_file_t *tf; | 179 ngx_temp_file_t *tf; |
167 | 187 |
168 for ( ;; ) { | 188 for ( ;; ) { |
169 if (rb->buf->last == rb->buf->end) { | 189 if (rb->buf->last == rb->buf->end) { |
170 | 190 |
171 if (rb->temp_file == NULL) { | 191 if (rb->temp_file == NULL) { |
172 if (!(tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) { | 192 tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)); |
193 if (tf == NULL) { | |
173 return NGX_ERROR; | 194 return NGX_ERROR; |
174 } | 195 } |
175 | 196 |
176 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 197 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
177 | 198 |
266 | 287 |
267 if (n == NGX_ERROR) { | 288 if (n == NGX_ERROR) { |
268 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 289 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
269 } | 290 } |
270 | 291 |
271 if (!(b = ngx_calloc_buf(r->pool))) { | 292 b = ngx_calloc_buf(r->pool); |
293 if (b == NULL) { | |
272 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 294 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
273 } | 295 } |
274 | 296 |
275 b->in_file = 1; | 297 b->in_file = 1; |
276 b->file_pos = 0; | 298 b->file_pos = 0; |