Mercurial > hg > nginx-quic
annotate src/http/ngx_http_header_filter_module.c @ 3373:78d3582a30af release-0.8.29
nginx-0.8.29-RELEASE
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 30 Nov 2009 13:28:12 +0000 |
parents | e0bc43a52382 |
children | e51e8ec95b50 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
439
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
439
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
439
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
439
diff
changeset
|
5 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
6 |
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
7 #include <ngx_config.h> |
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
8 #include <ngx_core.h> |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
9 #include <ngx_http.h> |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
10 #include <nginx.h> |
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
11 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
681 | 13 static ngx_int_t ngx_http_header_filter_init(ngx_conf_t *cf); |
356
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
14 static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r); |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
15 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
16 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
17 static ngx_http_module_t ngx_http_header_filter_module_ctx = { |
509 | 18 NULL, /* preconfiguration */ |
681 | 19 ngx_http_header_filter_init, /* postconfiguration */ |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
20 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
21 NULL, /* create main configuration */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
22 NULL, /* init main configuration */ |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
23 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
24 NULL, /* create server configuration */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
25 NULL, /* merge server configuration */ |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
26 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
27 NULL, /* create location configuration */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
28 NULL, /* merge location configuration */ |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
29 }; |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
30 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
32 ngx_module_t ngx_http_header_filter_module = { |
509 | 33 NGX_MODULE_V1, |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
34 &ngx_http_header_filter_module_ctx, /* module context */ |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
35 NULL, /* module directives */ |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
36 NGX_HTTP_MODULE, /* module type */ |
541 | 37 NULL, /* init master */ |
681 | 38 NULL, /* init module */ |
541 | 39 NULL, /* init process */ |
40 NULL, /* init thread */ | |
41 NULL, /* exit thread */ | |
42 NULL, /* exit process */ | |
43 NULL, /* exit master */ | |
44 NGX_MODULE_V1_PADDING | |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
45 }; |
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
46 |
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
47 |
1592 | 48 static char ngx_http_server_string[] = "Server: nginx" CRLF; |
49 static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF; | |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
50 |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
51 |
509 | 52 static ngx_str_t ngx_http_status_lines[] = { |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
53 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
54 ngx_string("200 OK"), |
633 | 55 ngx_string("201 Created"), |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
56 ngx_null_string, /* "202 Accepted" */ |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
57 ngx_null_string, /* "203 Non-Authoritative Information" */ |
511 | 58 ngx_string("204 No Content"), |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
59 ngx_null_string, /* "205 Reset Content" */ |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
60 ngx_string("206 Partial Content"), |
499 | 61 |
62 /* ngx_null_string, */ /* "207 Multi-Status" */ | |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
63 |
2696 | 64 #define NGX_HTTP_LAST_LEVEL_200 207 |
65 #define NGX_HTTP_LEVEL_200 (NGX_HTTP_LAST_LEVEL_200 - 200) | |
499 | 66 |
67 /* ngx_null_string, */ /* "300 Multiple Choices" */ | |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
68 |
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
69 ngx_string("301 Moved Permanently"), |
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
70 ngx_string("302 Moved Temporarily"), |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
71 ngx_null_string, /* "303 See Other" */ |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
72 ngx_string("304 Not Modified"), |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
73 |
499 | 74 /* ngx_null_string, */ /* "305 Use Proxy" */ |
75 /* ngx_null_string, */ /* "306 unused" */ | |
76 /* ngx_null_string, */ /* "307 Temporary Redirect" */ | |
77 | |
2696 | 78 #define NGX_HTTP_LAST_LEVEL_300 305 |
79 #define NGX_HTTP_LEVEL_300 (NGX_HTTP_LAST_LEVEL_300 - 301) | |
499 | 80 |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
81 ngx_string("400 Bad Request"), |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
82 ngx_string("401 Unauthorized"), |
499 | 83 ngx_string("402 Payment Required"), |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
84 ngx_string("403 Forbidden"), |
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
85 ngx_string("404 Not Found"), |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
86 ngx_string("405 Not Allowed"), |
499 | 87 ngx_string("406 Not Acceptable"), |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
88 ngx_null_string, /* "407 Proxy Authentication Required" */ |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
89 ngx_string("408 Request Time-out"), |
663 | 90 ngx_string("409 Conflict"), |
499 | 91 ngx_string("410 Gone"), |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
92 ngx_string("411 Length Required"), |
1057 | 93 ngx_string("412 Precondition Failed"), |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
94 ngx_string("413 Request Entity Too Large"), |
499 | 95 ngx_null_string, /* "414 Request-URI Too Large", but we never send it |
238
674f85a4d00f
nginx-0.0.1-2004-01-23-12:26:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
96 * because we treat such requests as the HTTP/0.9 |
674f85a4d00f
nginx-0.0.1-2004-01-23-12:26:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
97 * requests and send only a body without a header |
674f85a4d00f
nginx-0.0.1-2004-01-23-12:26:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
98 */ |
637 | 99 ngx_string("415 Unsupported Media Type"), |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
100 ngx_string("416 Requested Range Not Satisfiable"), |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
101 |
499 | 102 /* ngx_null_string, */ /* "417 Expectation Failed" */ |
103 /* ngx_null_string, */ /* "418 unused" */ | |
104 /* ngx_null_string, */ /* "419 unused" */ | |
105 /* ngx_null_string, */ /* "420 unused" */ | |
106 /* ngx_null_string, */ /* "421 unused" */ | |
107 /* ngx_null_string, */ /* "422 Unprocessable Entity" */ | |
108 /* ngx_null_string, */ /* "423 Locked" */ | |
109 /* ngx_null_string, */ /* "424 Failed Dependency" */ | |
110 | |
2696 | 111 #define NGX_HTTP_LAST_LEVEL_400 417 |
112 #define NGX_HTTP_LEVEL_400 (NGX_HTTP_LAST_LEVEL_400 - 400) | |
499 | 113 |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
114 ngx_string("500 Internal Server Error"), |
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
115 ngx_string("501 Method Not Implemented"), |
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
116 ngx_string("502 Bad Gateway"), |
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
117 ngx_string("503 Service Temporarily Unavailable"), |
637 | 118 ngx_string("504 Gateway Time-out"), |
499 | 119 |
637 | 120 ngx_null_string, /* "505 HTTP Version Not Supported" */ |
121 ngx_null_string, /* "506 Variant Also Negotiates" */ | |
122 ngx_string("507 Insufficient Storage"), | |
499 | 123 /* ngx_null_string, */ /* "508 unused" */ |
124 /* ngx_null_string, */ /* "509 unused" */ | |
125 /* ngx_null_string, */ /* "510 Not Extended" */ | |
2696 | 126 |
127 #define NGX_HTTP_LAST_LEVEL_500 508 | |
128 | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
129 }; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
130 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
131 |
569 | 132 ngx_http_header_out_t ngx_http_headers_out[] = { |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
133 { ngx_string("Server"), offsetof(ngx_http_headers_out_t, server) }, |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
134 { ngx_string("Date"), offsetof(ngx_http_headers_out_t, date) }, |
509 | 135 #if 0 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
136 { ngx_string("Content-Type"), |
499 | 137 offsetof(ngx_http_headers_out_t, content_type) }, |
509 | 138 #endif |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
139 { ngx_string("Content-Length"), |
499 | 140 offsetof(ngx_http_headers_out_t, content_length) }, |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
141 { ngx_string("Content-Encoding"), |
499 | 142 offsetof(ngx_http_headers_out_t, content_encoding) }, |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
143 { ngx_string("Location"), offsetof(ngx_http_headers_out_t, location) }, |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
144 { ngx_string("Last-Modified"), |
499 | 145 offsetof(ngx_http_headers_out_t, last_modified) }, |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
146 { ngx_string("Accept-Ranges"), |
499 | 147 offsetof(ngx_http_headers_out_t, accept_ranges) }, |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
148 { ngx_string("Expires"), offsetof(ngx_http_headers_out_t, expires) }, |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
149 { ngx_string("Cache-Control"), |
499 | 150 offsetof(ngx_http_headers_out_t, cache_control) }, |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
151 { ngx_string("ETag"), offsetof(ngx_http_headers_out_t, etag) }, |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
152 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
153 { ngx_null_string, 0 } |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
154 }; |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
155 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 |
493 | 157 static ngx_int_t |
158 ngx_http_header_filter(ngx_http_request_t *r) | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
159 { |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
160 u_char *p; |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
161 size_t len; |
2696 | 162 ngx_str_t host, *status_line; |
681 | 163 ngx_buf_t *b; |
2529 | 164 ngx_uint_t status, i, port; |
501 | 165 ngx_chain_t out; |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
166 ngx_list_part_t *part; |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
167 ngx_table_elt_t *header; |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
168 ngx_connection_t *c; |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
169 ngx_http_core_loc_conf_t *clcf; |
1811 | 170 ngx_http_core_srv_conf_t *cscf; |
2529 | 171 struct sockaddr_in *sin; |
172 #if (NGX_HAVE_INET6) | |
173 struct sockaddr_in6 *sin6; | |
174 #endif | |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2197
diff
changeset
|
175 u_char addr[NGX_SOCKADDR_STRLEN]; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
176 |
667 | 177 r->header_sent = 1; |
178 | |
3331
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
179 if (r != r->main) { |
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
180 return NGX_OK; |
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
181 } |
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
182 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
183 if (r->http_version < NGX_HTTP_VERSION_10) { |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
184 return NGX_OK; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
185 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
186 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
187 if (r->method == NGX_HTTP_HEAD) { |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
188 r->header_only = 1; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
189 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
190 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
191 if (r->headers_out.last_modified_time != -1) { |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
192 if (r->headers_out.status != NGX_HTTP_OK |
511 | 193 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT |
194 && r->headers_out.status != NGX_HTTP_NOT_MODIFIED) | |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
195 { |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
196 r->headers_out.last_modified_time = -1; |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
197 r->headers_out.last_modified = NULL; |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
198 } |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
199 } |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
200 |
493 | 201 len = sizeof("HTTP/1.x ") - 1 + sizeof(CRLF) - 1 |
202 /* the end of the header */ | |
203 + sizeof(CRLF) - 1; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
204 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
205 /* status line */ |
452 | 206 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
207 if (r->headers_out.status_line.len) { |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
208 len += r->headers_out.status_line.len; |
2696 | 209 status_line = &r->headers_out.status_line; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
47
diff
changeset
|
210 #if (NGX_SUPPRESS_WARN) |
2696 | 211 status = 0; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
47
diff
changeset
|
212 #endif |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
213 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
214 } else { |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
177
diff
changeset
|
215 |
2696 | 216 status = r->headers_out.status; |
217 | |
218 if (status >= NGX_HTTP_OK | |
219 && status < NGX_HTTP_LAST_LEVEL_200) | |
220 { | |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
221 /* 2XX */ |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
222 |
2696 | 223 if (status == NGX_HTTP_NO_CONTENT) { |
511 | 224 r->header_only = 1; |
225 r->headers_out.content_type.len = 0; | |
226 r->headers_out.content_type.data = NULL; | |
227 r->headers_out.last_modified_time = -1; | |
228 r->headers_out.last_modified = NULL; | |
229 r->headers_out.content_length = NULL; | |
230 r->headers_out.content_length_n = -1; | |
231 } | |
232 | |
2696 | 233 status -= NGX_HTTP_OK; |
234 status_line = &ngx_http_status_lines[status]; | |
235 len += ngx_http_status_lines[status].len; | |
236 | |
237 } else if (status >= NGX_HTTP_MOVED_PERMANENTLY | |
238 && status < NGX_HTTP_LAST_LEVEL_300) | |
239 { | |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
240 /* 3XX */ |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
241 |
2696 | 242 if (status == NGX_HTTP_NOT_MODIFIED) { |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
243 r->header_only = 1; |
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
244 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
245 |
2696 | 246 status = status - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_LEVEL_200; |
247 status_line = &ngx_http_status_lines[status]; | |
248 len += ngx_http_status_lines[status].len; | |
249 | |
250 } else if (status >= NGX_HTTP_BAD_REQUEST | |
2700
aee784753144
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
2696
diff
changeset
|
251 && status < NGX_HTTP_LAST_LEVEL_400) |
2696 | 252 { |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
253 /* 4XX */ |
2696 | 254 status = status - NGX_HTTP_BAD_REQUEST |
255 + NGX_HTTP_LEVEL_200 | |
256 + NGX_HTTP_LEVEL_300; | |
257 | |
258 status_line = &ngx_http_status_lines[status]; | |
259 len += ngx_http_status_lines[status].len; | |
260 | |
261 } else if (status >= NGX_HTTP_INTERNAL_SERVER_ERROR | |
262 && status < NGX_HTTP_LAST_LEVEL_500) | |
263 { | |
264 /* 5XX */ | |
265 status = status - NGX_HTTP_INTERNAL_SERVER_ERROR | |
266 + NGX_HTTP_LEVEL_200 | |
267 + NGX_HTTP_LEVEL_300 | |
268 + NGX_HTTP_LEVEL_400; | |
269 | |
270 status_line = &ngx_http_status_lines[status]; | |
271 len += ngx_http_status_lines[status].len; | |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
272 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
273 } else { |
2696 | 274 len += NGX_INT_T_LEN; |
275 status_line = NULL; | |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
276 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
277 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
278 |
1592 | 279 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
280 | |
509 | 281 if (r->headers_out.server == NULL) { |
1592 | 282 len += clcf->server_tokens ? sizeof(ngx_http_server_full_string) - 1: |
283 sizeof(ngx_http_server_string) - 1; | |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
284 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
285 |
509 | 286 if (r->headers_out.date == NULL) { |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
287 len += sizeof("Date: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
288 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
289 |
509 | 290 if (r->headers_out.content_type.len) { |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
291 len += sizeof("Content-Type: ") - 1 |
509 | 292 + r->headers_out.content_type.len + 2; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
293 |
657 | 294 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
295 && r->headers_out.charset.len) | |
296 { | |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
297 len += sizeof("; charset=") - 1 + r->headers_out.charset.len; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
298 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
299 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
300 |
509 | 301 if (r->headers_out.content_length == NULL |
302 && r->headers_out.content_length_n >= 0) | |
303 { | |
304 len += sizeof("Content-Length: ") - 1 + NGX_OFF_T_LEN + 2; | |
305 } | |
306 | |
307 if (r->headers_out.last_modified == NULL | |
308 && r->headers_out.last_modified_time != -1) | |
309 { | |
310 len += sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1; | |
311 } | |
312 | |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
313 c = r->connection; |
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
314 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
315 if (r->headers_out.location |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
316 && r->headers_out.location->value.len |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
317 && r->headers_out.location->value.data[0] == '/') |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
318 { |
509 | 319 r->headers_out.location->hash = 0; |
320 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
321 if (clcf->server_name_in_redirect) { |
1811 | 322 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
323 host = cscf->server_name; | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
324 |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
325 } else if (r->headers_in.server.len) { |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
326 host = r->headers_in.server; |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
327 |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
328 } else { |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2197
diff
changeset
|
329 host.len = NGX_SOCKADDR_STRLEN; |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
330 host.data = addr; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
331 |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
332 if (ngx_connection_local_sockaddr(c, &host, 0) != NGX_OK) { |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
333 return NGX_ERROR; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
334 } |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
335 } |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
336 |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
337 switch (c->local_sockaddr->sa_family) { |
2529 | 338 |
339 #if (NGX_HAVE_INET6) | |
340 case AF_INET6: | |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
341 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; |
2531 | 342 port = ntohs(sin6->sin6_port); |
2529 | 343 break; |
344 #endif | |
345 default: /* AF_INET */ | |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
346 sin = (struct sockaddr_in *) c->local_sockaddr; |
2531 | 347 port = ntohs(sin->sin_port); |
2529 | 348 break; |
349 } | |
350 | |
2533 | 351 len += sizeof("Location: https://") - 1 |
352 + host.len | |
353 + r->headers_out.location->value.len + 2; | |
517 | 354 |
2533 | 355 if (clcf->port_in_redirect) { |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
356 |
2533 | 357 #if (NGX_HTTP_SSL) |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
358 if (c->ssl) |
2551 | 359 port = (port == 443) ? 0 : port; |
360 else | |
517 | 361 #endif |
2551 | 362 port = (port == 80) ? 0 : port; |
2768
e4a4c889694f
"port_in_redirect off" did not work
Igor Sysoev <igor@sysoev.ru>
parents:
2709
diff
changeset
|
363 |
e4a4c889694f
"port_in_redirect off" did not work
Igor Sysoev <igor@sysoev.ru>
parents:
2709
diff
changeset
|
364 } else { |
e4a4c889694f
"port_in_redirect off" did not work
Igor Sysoev <igor@sysoev.ru>
parents:
2709
diff
changeset
|
365 port = 0; |
2551 | 366 } |
517 | 367 |
2533 | 368 if (port) { |
369 len += sizeof(":65535") - 1; | |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
370 } |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
371 |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
372 } else { |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
373 host.len = 0; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
374 host.data = NULL; |
2529 | 375 port = 0; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
376 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
10
diff
changeset
|
377 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
378 if (r->chunked) { |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
379 len += sizeof("Transfer-Encoding: chunked" CRLF) - 1; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
380 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
381 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
382 if (r->keepalive) { |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
383 len += sizeof("Connection: keep-alive" CRLF) - 1; |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
384 |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
385 /* |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
386 * MSIE and Opera ignore the "Keep-Alive: timeout=<N>" header. |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
387 * MSIE keeps the connection alive for about 60-65 seconds. |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
388 * Opera keeps the connection alive very long. |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
389 * Mozilla keeps the connection alive for N plus about 1-10 seconds. |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
390 * Konqueror keeps the connection alive for about N seconds. |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
391 */ |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
392 |
473 | 393 if (clcf->keepalive_header) { |
477 | 394 len += sizeof("Keep-Alive: timeout=") - 1 + NGX_TIME_T_LEN + 2; |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
395 } |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
396 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
397 } else { |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
398 len += sizeof("Connection: closed" CRLF) - 1; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
399 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
400 |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
401 #if (NGX_HTTP_GZIP) |
3313 | 402 if (r->gzip_vary) { |
403 if (clcf->gzip_vary) { | |
404 len += sizeof("Vary: Accept-Encoding" CRLF) - 1; | |
405 | |
406 } else { | |
407 r->gzip_vary = 0; | |
408 } | |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
409 } |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
410 #endif |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
411 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
412 part = &r->headers_out.headers.part; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
413 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
414 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
415 for (i = 0; /* void */; i++) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
416 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
417 if (i >= part->nelts) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
418 if (part->next == NULL) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
419 break; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
420 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
421 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
422 part = part->next; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
423 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
424 i = 0; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
425 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
426 |
509 | 427 if (header[i].hash == 0) { |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
428 continue; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
429 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
430 |
493 | 431 len += header[i].key.len + sizeof(": ") - 1 + header[i].value.len |
432 + sizeof(CRLF) - 1; | |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
433 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
434 |
501 | 435 b = ngx_create_temp_buf(r->pool, len); |
436 if (b == NULL) { | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
437 return NGX_ERROR; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
438 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
439 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
440 /* "HTTP/1.x " */ |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
441 b->last = ngx_cpymem(b->last, "HTTP/1.1 ", sizeof("HTTP/1.x ") - 1); |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
442 |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
443 /* status line */ |
2696 | 444 if (status_line) { |
445 b->last = ngx_copy(b->last, status_line->data, status_line->len); | |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
446 |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
447 } else { |
2696 | 448 b->last = ngx_sprintf(b->last, "%ui", status); |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
449 } |
493 | 450 *b->last++ = CR; *b->last++ = LF; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
451 |
509 | 452 if (r->headers_out.server == NULL) { |
1592 | 453 if (clcf->server_tokens) { |
1594 | 454 p = (u_char *) ngx_http_server_full_string; |
1592 | 455 len = sizeof(ngx_http_server_full_string) - 1; |
456 | |
457 } else { | |
1594 | 458 p = (u_char *) ngx_http_server_string; |
1592 | 459 len = sizeof(ngx_http_server_string) - 1; |
460 } | |
461 | |
462 b->last = ngx_cpymem(b->last, p, len); | |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
463 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
464 |
509 | 465 if (r->headers_out.date == NULL) { |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
466 b->last = ngx_cpymem(b->last, "Date: ", sizeof("Date: ") - 1); |
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
467 b->last = ngx_cpymem(b->last, ngx_cached_http_time.data, |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
177
diff
changeset
|
468 ngx_cached_http_time.len); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
469 |
493 | 470 *b->last++ = CR; *b->last++ = LF; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
471 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
472 |
509 | 473 if (r->headers_out.content_type.len) { |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
474 b->last = ngx_cpymem(b->last, "Content-Type: ", |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
475 sizeof("Content-Type: ") - 1); |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
476 p = b->last; |
573 | 477 b->last = ngx_copy(b->last, r->headers_out.content_type.data, |
478 r->headers_out.content_type.len); | |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
479 |
657 | 480 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
481 && r->headers_out.charset.len) | |
482 { | |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
483 b->last = ngx_cpymem(b->last, "; charset=", |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
484 sizeof("; charset=") - 1); |
573 | 485 b->last = ngx_copy(b->last, r->headers_out.charset.data, |
486 r->headers_out.charset.len); | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
487 |
509 | 488 /* update r->headers_out.content_type for possible logging */ |
489 | |
490 r->headers_out.content_type.len = b->last - p; | |
491 r->headers_out.content_type.data = p; | |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
492 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
493 |
493 | 494 *b->last++ = CR; *b->last++ = LF; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
495 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
496 |
509 | 497 if (r->headers_out.content_length == NULL |
498 && r->headers_out.content_length_n >= 0) | |
499 { | |
500 b->last = ngx_sprintf(b->last, "Content-Length: %O" CRLF, | |
501 r->headers_out.content_length_n); | |
502 } | |
503 | |
504 if (r->headers_out.last_modified == NULL | |
505 && r->headers_out.last_modified_time != -1) | |
506 { | |
507 b->last = ngx_cpymem(b->last, "Last-Modified: ", | |
508 sizeof("Last-Modified: ") - 1); | |
509 b->last = ngx_http_time(b->last, r->headers_out.last_modified_time); | |
510 | |
511 *b->last++ = CR; *b->last++ = LF; | |
512 } | |
513 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
514 if (host.data) { |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
515 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
516 p = b->last + sizeof("Location: ") - 1; |
517 | 517 |
518 b->last = ngx_cpymem(b->last, "Location: http", | |
519 sizeof("Location: http") - 1); | |
520 | |
521 #if (NGX_HTTP_SSL) | |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
522 if (c->ssl) { |
517 | 523 *b->last++ ='s'; |
524 } | |
525 #endif | |
526 | |
527 *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/'; | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
528 b->last = ngx_copy(b->last, host.data, host.len); |
517 | 529 |
2533 | 530 if (port) { |
531 b->last = ngx_sprintf(b->last, ":%ui", port); | |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
532 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
533 |
573 | 534 b->last = ngx_copy(b->last, r->headers_out.location->value.data, |
535 r->headers_out.location->value.len); | |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
536 |
509 | 537 /* update r->headers_out.location->value for possible logging */ |
538 | |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
539 r->headers_out.location->value.len = b->last - p; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
540 r->headers_out.location->value.data = p; |
669 | 541 r->headers_out.location->key.len = sizeof("Location: ") - 1; |
542 r->headers_out.location->key.data = (u_char *) "Location: "; | |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
166
diff
changeset
|
543 |
493 | 544 *b->last++ = CR; *b->last++ = LF; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
545 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
10
diff
changeset
|
546 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
547 if (r->chunked) { |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
548 b->last = ngx_cpymem(b->last, "Transfer-Encoding: chunked" CRLF, |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
549 sizeof("Transfer-Encoding: chunked" CRLF) - 1); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
550 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
551 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
552 if (r->keepalive) { |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
553 b->last = ngx_cpymem(b->last, "Connection: keep-alive" CRLF, |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
554 sizeof("Connection: keep-alive" CRLF) - 1); |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
555 |
473 | 556 if (clcf->keepalive_header) { |
455 | 557 b->last = ngx_sprintf(b->last, "Keep-Alive: timeout=%T" CRLF, |
558 clcf->keepalive_header); | |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
559 } |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
560 |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
561 } else { |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
562 b->last = ngx_cpymem(b->last, "Connection: close" CRLF, |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
563 sizeof("Connection: close" CRLF) - 1); |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
564 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
565 |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
566 #if (NGX_HTTP_GZIP) |
3313 | 567 if (r->gzip_vary) { |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
568 b->last = ngx_cpymem(b->last, "Vary: Accept-Encoding" CRLF, |
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
569 sizeof("Vary: Accept-Encoding" CRLF) - 1); |
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
570 } |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
571 #endif |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
572 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
573 part = &r->headers_out.headers.part; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
574 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
575 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
576 for (i = 0; /* void */; i++) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
577 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
578 if (i >= part->nelts) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
579 if (part->next == NULL) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
580 break; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
581 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
582 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
583 part = part->next; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
584 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
585 i = 0; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
586 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
587 |
509 | 588 if (header[i].hash == 0) { |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
589 continue; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
590 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
591 |
573 | 592 b->last = ngx_copy(b->last, header[i].key.data, header[i].key.len); |
2024 | 593 *b->last++ = ':'; *b->last++ = ' '; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
594 |
573 | 595 b->last = ngx_copy(b->last, header[i].value.data, header[i].value.len); |
493 | 596 *b->last++ = CR; *b->last++ = LF; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
597 } |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
598 |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
599 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
2709 | 600 "%*s", (size_t) (b->last - b->pos), b->pos); |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
601 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
602 /* the end of HTTP header */ |
493 | 603 *b->last++ = CR; *b->last++ = LF; |
2
ffffe1499bce
nginx-0.0.1-2002-08-16-19:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
604 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
605 r->header_size = b->last - b->pos; |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
606 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
607 if (r->header_only) { |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
608 b->last_buf = 1; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
609 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
610 |
501 | 611 out.buf = b; |
612 out.next = NULL; | |
2
ffffe1499bce
nginx-0.0.1-2002-08-16-19:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
613 |
501 | 614 return ngx_http_write_filter(r, &out); |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
615 } |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
616 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
617 |
493 | 618 static ngx_int_t |
681 | 619 ngx_http_header_filter_init(ngx_conf_t *cf) |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
620 { |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
621 ngx_http_top_header_filter = ngx_http_header_filter; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
622 |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
623 return NGX_OK; |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
624 } |