Mercurial > hg > nginx-quic
comparison src/http/ngx_http_header_filter.c @ 165:894a01c6aea3
nginx-0.0.1-2003-10-29-20:39:05 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 29 Oct 2003 17:39:05 +0000 |
parents | 84036764e215 |
children | 389d7ee9fa60 |
comparison
equal
deleted
inserted
replaced
164:84036764e215 | 165:894a01c6aea3 |
---|---|
150 + r->headers_out.date->value.len + 2; | 150 + r->headers_out.date->value.len + 2; |
151 } else { | 151 } else { |
152 len += sizeof("Date: Mon, 28 Sep 1970 00:00:00 GMT" CRLF) - 1; | 152 len += sizeof("Date: Mon, 28 Sep 1970 00:00:00 GMT" CRLF) - 1; |
153 } | 153 } |
154 | 154 |
155 if (r->headers_out.content_range && r->headers_out.content_range->value.len) | |
156 { | |
157 len += sizeof("Content-Range: ") - 1 | |
158 + r->headers_out.content_range->value.len + 2; | |
159 } | |
160 | |
161 if (r->headers_out.content_length == NULL) { | 155 if (r->headers_out.content_length == NULL) { |
162 if (r->headers_out.content_length_n >= 0) { | 156 if (r->headers_out.content_length_n >= 0) { |
163 /* 2^64 */ | 157 /* 2^64 */ |
164 len += sizeof("Content-Length: 18446744073709551616" CRLF) - 1; | 158 len += sizeof("Content-Length: 18446744073709551616" CRLF) - 1; |
165 } | 159 } |
166 } | 160 } |
167 | 161 |
168 if (r->headers_out.content_type && r->headers_out.content_type->value.len) { | 162 if (r->headers_out.content_type && r->headers_out.content_type->value.len) { |
171 + r->headers_out.content_type->value.len + 2; | 165 + r->headers_out.content_type->value.len + 2; |
172 | 166 |
173 if (r->headers_out.charset.len) { | 167 if (r->headers_out.charset.len) { |
174 len += sizeof("; charset=") - 1 + r->headers_out.charset.len; | 168 len += sizeof("; charset=") - 1 + r->headers_out.charset.len; |
175 } | 169 } |
176 } | |
177 | |
178 if (r->headers_out.content_encoding | |
179 && r->headers_out.content_encoding->value.len) | |
180 { | |
181 len += 18 + r->headers_out.content_encoding->value.len + 2; | |
182 } | 170 } |
183 | 171 |
184 if (r->headers_out.location | 172 if (r->headers_out.location |
185 && r->headers_out.location->value.len | 173 && r->headers_out.location->value.len |
186 && r->headers_out.location->value.data[0] == '/') | 174 && r->headers_out.location->value.data[0] == '/') |
216 for (i = 0; i < r->headers_out.headers->nelts; i++) { | 204 for (i = 0; i < r->headers_out.headers->nelts; i++) { |
217 if (header[i].key.len == 0) { | 205 if (header[i].key.len == 0) { |
218 continue; | 206 continue; |
219 } | 207 } |
220 | 208 |
209 /* 2 is for ": " and 2 is for "\r\n" */ | |
221 len += header[i].key.len + 2 + header[i].value.len + 2; | 210 len += header[i].key.len + 2 + header[i].value.len + 2; |
222 } | 211 } |
223 | 212 |
224 ngx_test_null(h, ngx_create_temp_hunk(r->pool, len, 0, 64), NGX_ERROR); | 213 ngx_test_null(h, ngx_create_temp_hunk(r->pool, len, 0, 0), NGX_ERROR); |
225 | 214 |
226 /* "HTTP/1.x " */ | 215 /* "HTTP/1.x " */ |
227 h->last = ngx_cpymem(h->last, "HTTP/1.1 ", sizeof("HTTP/1.x ") - 1); | 216 h->last = ngx_cpymem(h->last, "HTTP/1.1 ", sizeof("HTTP/1.x ") - 1); |
228 | 217 |
229 /* status line */ | 218 /* status line */ |
245 h->last = ngx_cpymem(h->last, "Date: ", sizeof("Date: ") - 1); | 234 h->last = ngx_cpymem(h->last, "Date: ", sizeof("Date: ") - 1); |
246 h->last += ngx_http_get_time(h->last, time(NULL)); | 235 h->last += ngx_http_get_time(h->last, time(NULL)); |
247 *(h->last++) = CR; *(h->last++) = LF; | 236 *(h->last++) = CR; *(h->last++) = LF; |
248 } | 237 } |
249 | 238 |
250 | |
251 if (r->headers_out.content_range && r->headers_out.content_range->value.len) | |
252 { | |
253 h->last = ngx_cpymem(h->last, "Content-Range: ", | |
254 sizeof("Content-Range: ") - 1); | |
255 h->last = ngx_cpymem(h->last, r->headers_out.content_range->value.data, | |
256 r->headers_out.content_range->value.len); | |
257 *(h->last++) = CR; *(h->last++) = LF; | |
258 } | |
259 | |
260 if (r->headers_out.content_length == NULL) { | 239 if (r->headers_out.content_length == NULL) { |
261 /* 2^64 is 20 characters */ | |
262 if (r->headers_out.content_length_n >= 0) { | 240 if (r->headers_out.content_length_n >= 0) { |
263 h->last += ngx_snprintf(h->last, | 241 h->last += ngx_snprintf(h->last, /* 2^64 */ |
264 sizeof("Content-Length: 18446744073709551616" CRLF), | 242 sizeof("Content-Length: 18446744073709551616" CRLF), |
265 "Content-Length: " OFF_FMT CRLF, | 243 "Content-Length: " OFF_FMT CRLF, |
266 r->headers_out.content_length_n); | 244 r->headers_out.content_length_n); |
267 } | 245 } |
268 } | 246 } |
277 h->last = ngx_cpymem(h->last, "; charset=", | 255 h->last = ngx_cpymem(h->last, "; charset=", |
278 sizeof("; charset=") - 1); | 256 sizeof("; charset=") - 1); |
279 h->last = ngx_cpymem(h->last, r->headers_out.charset.data, | 257 h->last = ngx_cpymem(h->last, r->headers_out.charset.data, |
280 r->headers_out.charset.len); | 258 r->headers_out.charset.len); |
281 } | 259 } |
282 | |
283 *(h->last++) = CR; *(h->last++) = LF; | |
284 } | |
285 | |
286 if (r->headers_out.content_encoding | |
287 && r->headers_out.content_encoding->value.len) | |
288 { | |
289 h->last = ngx_cpymem(h->last, "Content-Encoding: ", | |
290 sizeof("Content-Encoding: ") - 1); | |
291 h->last = ngx_cpymem(h->last, | |
292 r->headers_out.content_encoding->value.data, | |
293 r->headers_out.content_encoding->value.len); | |
294 | 260 |
295 *(h->last++) = CR; *(h->last++) = LF; | 261 *(h->last++) = CR; *(h->last++) = LF; |
296 } | 262 } |
297 | 263 |
298 if (r->headers_out.location | 264 if (r->headers_out.location |