Mercurial > hg > nginx
comparison src/http/ngx_http_request_body.c @ 343:6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 28 May 2004 15:49:23 +0000 |
parents | 00c5660d2707 |
children | 6f3b20c1ac50 |
comparison
equal
deleted
inserted
replaced
342:0ee0642af5f1 | 343:6bdf858bff8c |
---|---|
10 | 10 |
11 | 11 |
12 ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r) | 12 ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r) |
13 { | 13 { |
14 ssize_t size; | 14 ssize_t size; |
15 ngx_hunk_t *h; | 15 ngx_buf_t *b; |
16 ngx_chain_t *cl; | 16 ngx_chain_t *cl; |
17 ngx_http_core_loc_conf_t *clcf; | 17 ngx_http_core_loc_conf_t *clcf; |
18 | 18 |
19 size = r->header_in->last - r->header_in->pos; | 19 size = r->header_in->last - r->header_in->pos; |
20 | 20 |
21 if (size) { | 21 if (size) { |
22 | 22 |
23 /* there is the pre-read part of the request body */ | 23 /* there is the pre-read part of the request body */ |
24 | 24 |
25 ngx_test_null(h, ngx_calloc_hunk(r->pool), | 25 ngx_test_null(b, ngx_calloc_buf(r->pool), |
26 NGX_HTTP_INTERNAL_SERVER_ERROR); | 26 NGX_HTTP_INTERNAL_SERVER_ERROR); |
27 | 27 |
28 h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP; | 28 b->temporary = 1; |
29 h->start = h->pos = r->header_in->pos; | 29 b->start = b->pos = r->header_in->pos; |
30 h->end = h->last = r->header_in->last; | 30 b->end = b->last = r->header_in->last; |
31 | 31 |
32 ngx_alloc_link_and_set_hunk(r->request_body->bufs, h, r->pool, | 32 ngx_alloc_link_and_set_buf(r->request_body->bufs, b, r->pool, |
33 NGX_HTTP_INTERNAL_SERVER_ERROR); | 33 NGX_HTTP_INTERNAL_SERVER_ERROR); |
34 | 34 |
35 if (size >= r->headers_in.content_length_n) { | 35 if (size >= r->headers_in.content_length_n) { |
36 | 36 |
37 /* the whole request body was pre-read */ | 37 /* the whole request body was pre-read */ |
59 | 59 |
60 } else { | 60 } else { |
61 size = clcf->client_body_buffer_size; | 61 size = clcf->client_body_buffer_size; |
62 } | 62 } |
63 | 63 |
64 ngx_test_null(r->request_body->buf, ngx_create_temp_hunk(r->pool, size), | 64 ngx_test_null(r->request_body->buf, ngx_create_temp_buf(r->pool, size), |
65 NGX_HTTP_INTERNAL_SERVER_ERROR); | 65 NGX_HTTP_INTERNAL_SERVER_ERROR); |
66 | 66 |
67 ngx_alloc_link_and_set_hunk(cl, r->request_body->buf, r->pool, | 67 ngx_alloc_link_and_set_buf(cl, r->request_body->buf, r->pool, |
68 NGX_HTTP_INTERNAL_SERVER_ERROR); | 68 NGX_HTTP_INTERNAL_SERVER_ERROR); |
69 | 69 |
70 if (r->request_body->bufs) { | 70 if (r->request_body->bufs) { |
71 r->request_body->bufs->next = cl; | 71 r->request_body->bufs->next = cl; |
72 | 72 |
73 } else { | 73 } else { |
105 | 105 |
106 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r) | 106 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r) |
107 { | 107 { |
108 size_t size; | 108 size_t size; |
109 ssize_t n; | 109 ssize_t n; |
110 ngx_hunk_t *h; | 110 ngx_buf_t *b; |
111 ngx_connection_t *c; | 111 ngx_connection_t *c; |
112 ngx_http_core_loc_conf_t *clcf; | 112 ngx_http_core_loc_conf_t *clcf; |
113 | 113 |
114 c = r->connection; | 114 c = r->connection; |
115 | 115 |
197 | 197 |
198 if (n == NGX_ERROR) { | 198 if (n == NGX_ERROR) { |
199 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 199 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
200 } | 200 } |
201 | 201 |
202 h = ngx_calloc_hunk(r->pool); | 202 if (!(b = ngx_calloc_buf(r->pool))) { |
203 if (h == NULL) { | |
204 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 203 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
205 } | 204 } |
206 | 205 |
207 h->type = NGX_HUNK_FILE; | 206 b->in_file = 1; |
208 h->file_pos = 0; | 207 b->file_pos = 0; |
209 h->file_last = r->request_body->temp_file->file.offset; | 208 b->file_last = r->request_body->temp_file->file.offset; |
210 h->file = &r->request_body->temp_file->file; | 209 b->file = &r->request_body->temp_file->file; |
211 | 210 |
212 if (r->request_body->bufs->next) { | 211 if (r->request_body->bufs->next) { |
213 r->request_body->bufs->next->hunk = h; | 212 r->request_body->bufs->next->buf = b; |
214 | 213 |
215 } else { | 214 } else { |
216 r->request_body->bufs->hunk = h; | 215 r->request_body->bufs->buf = b; |
217 } | 216 } |
218 } | 217 } |
219 | 218 |
220 r->request_body->handler(r->request_body->data); | 219 r->request_body->handler(r->request_body->data); |
221 | 220 |