Mercurial > hg > nginx
comparison src/http/modules/ngx_http_chunked_filter.c @ 336:ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 18 May 2004 15:29:08 +0000 |
parents | a472bfb778b3 |
children | 4feff829a849 |
comparison
equal
deleted
inserted
replaced
335:d4241d7787fe | 336:ca9a7f8c86da |
---|---|
64 if (in == NULL || !r->chunked) { | 64 if (in == NULL || !r->chunked) { |
65 return ngx_http_next_body_filter(r, in); | 65 return ngx_http_next_body_filter(r, in); |
66 } | 66 } |
67 | 67 |
68 ngx_test_null(out, ngx_alloc_chain_link(r->pool), NGX_ERROR); | 68 ngx_test_null(out, ngx_alloc_chain_link(r->pool), NGX_ERROR); |
69 out->hunk = NULL; | |
69 ll = &out->next; | 70 ll = &out->next; |
70 | 71 |
71 size = 0; | 72 size = 0; |
72 cl = in; | 73 cl = in; |
73 | 74 |
74 for ( ;; ) { | 75 for ( ;; ) { |
76 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
77 "http chunk: %d", ngx_hunk_size(cl->hunk)); | |
78 | |
75 size += ngx_hunk_size(cl->hunk); | 79 size += ngx_hunk_size(cl->hunk); |
76 | 80 |
77 ngx_test_null(tl, ngx_alloc_chain_link(r->pool), NGX_ERROR); | 81 ngx_test_null(tl, ngx_alloc_chain_link(r->pool), NGX_ERROR); |
78 tl->hunk = cl->hunk; | 82 tl->hunk = cl->hunk; |
79 *ll = tl; | 83 *ll = tl; |
84 } | 88 } |
85 | 89 |
86 cl = cl->next; | 90 cl = cl->next; |
87 } | 91 } |
88 | 92 |
89 ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR); | 93 if (size) { |
90 len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size); | 94 ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR); |
95 len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size); | |
91 | 96 |
92 ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR); | 97 ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR); |
93 h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP; | 98 h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP; |
94 h->pos = chunk; | 99 h->pos = chunk; |
95 h->last = chunk + len; | 100 h->last = chunk + len; |
96 | 101 |
97 out->hunk = h; | 102 out->hunk = h; |
98 | 103 } |
99 ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR); | |
100 | 104 |
101 if (cl->hunk->type & NGX_HUNK_LAST) { | 105 if (cl->hunk->type & NGX_HUNK_LAST) { |
102 cl->hunk->type &= ~NGX_HUNK_LAST; | 106 |
107 ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR); | |
103 h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY|NGX_HUNK_LAST; | 108 h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY|NGX_HUNK_LAST; |
104 h->pos = (u_char *) CRLF "0" CRLF CRLF; | 109 h->pos = (u_char *) CRLF "0" CRLF CRLF; |
105 h->last = h->pos + 7; | 110 h->last = h->pos + 7; |
106 | 111 |
112 cl->hunk->type &= ~NGX_HUNK_LAST; | |
113 | |
114 if (size == 0) { | |
115 out->hunk = h; | |
116 out->next = NULL; | |
117 | |
118 return ngx_http_next_body_filter(r, out); | |
119 } | |
120 | |
107 } else { | 121 } else { |
122 if (size == 0) { | |
123 *ll = NULL; | |
124 return ngx_http_next_body_filter(r, out->next); | |
125 } | |
126 | |
127 ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR); | |
108 h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY; | 128 h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY; |
109 h->pos = (u_char *) CRLF; | 129 h->pos = (u_char *) CRLF; |
110 h->last = h->pos + 2; | 130 h->last = h->pos + 2; |
111 } | 131 } |
112 | 132 |