Mercurial > hg > nginx
annotate src/http/ngx_http_header_filter_module.c @ 3496:fb88801564de
build nginx/Windows against OpenSSL-0.9.8n, since nginx-0.8.35
built against OpenSSL-1.0.0 crashed on Windows XP somewhere
in the NTDLL.DLL on the master process exit
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 21 Apr 2010 15:09:17 +0000 |
parents | 192b727c2563 |
children | dd1570b6f237 |
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) }, |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
135 { ngx_string("Content-Length"), |
499 | 136 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
|
137 { ngx_string("Content-Encoding"), |
499 | 138 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
|
139 { 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
|
140 { ngx_string("Last-Modified"), |
499 | 141 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
|
142 { ngx_string("Accept-Ranges"), |
499 | 143 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
|
144 { 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
|
145 { ngx_string("Cache-Control"), |
499 | 146 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
|
147 { 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
|
148 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
149 { 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
|
150 }; |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
151 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
152 |
493 | 153 static ngx_int_t |
154 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
|
155 { |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
156 u_char *p; |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
157 size_t len; |
2696 | 158 ngx_str_t host, *status_line; |
681 | 159 ngx_buf_t *b; |
2529 | 160 ngx_uint_t status, i, port; |
501 | 161 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
|
162 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
|
163 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
|
164 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
|
165 ngx_http_core_loc_conf_t *clcf; |
1811 | 166 ngx_http_core_srv_conf_t *cscf; |
2529 | 167 struct sockaddr_in *sin; |
168 #if (NGX_HAVE_INET6) | |
169 struct sockaddr_in6 *sin6; | |
170 #endif | |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2197
diff
changeset
|
171 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
|
172 |
667 | 173 r->header_sent = 1; |
174 | |
3331
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
175 if (r != r->main) { |
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
176 return NGX_OK; |
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
177 } |
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
178 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
179 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
|
180 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
|
181 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
182 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
183 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
|
184 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
|
185 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
186 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
187 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
|
188 if (r->headers_out.status != NGX_HTTP_OK |
511 | 189 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT |
190 && 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
|
191 { |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
192 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
|
193 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
|
194 } |
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 |
493 | 197 len = sizeof("HTTP/1.x ") - 1 + sizeof(CRLF) - 1 |
198 /* the end of the header */ | |
199 + sizeof(CRLF) - 1; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
201 /* status line */ |
452 | 202 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
203 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
|
204 len += r->headers_out.status_line.len; |
2696 | 205 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
|
206 #if (NGX_SUPPRESS_WARN) |
2696 | 207 status = 0; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
47
diff
changeset
|
208 #endif |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
209 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
210 } else { |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
177
diff
changeset
|
211 |
2696 | 212 status = r->headers_out.status; |
213 | |
214 if (status >= NGX_HTTP_OK | |
215 && status < NGX_HTTP_LAST_LEVEL_200) | |
216 { | |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
217 /* 2XX */ |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
218 |
2696 | 219 if (status == NGX_HTTP_NO_CONTENT) { |
511 | 220 r->header_only = 1; |
221 r->headers_out.content_type.len = 0; | |
222 r->headers_out.content_type.data = NULL; | |
223 r->headers_out.last_modified_time = -1; | |
224 r->headers_out.last_modified = NULL; | |
225 r->headers_out.content_length = NULL; | |
226 r->headers_out.content_length_n = -1; | |
227 } | |
228 | |
2696 | 229 status -= NGX_HTTP_OK; |
230 status_line = &ngx_http_status_lines[status]; | |
231 len += ngx_http_status_lines[status].len; | |
232 | |
233 } else if (status >= NGX_HTTP_MOVED_PERMANENTLY | |
234 && status < NGX_HTTP_LAST_LEVEL_300) | |
235 { | |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
236 /* 3XX */ |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
237 |
2696 | 238 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
|
239 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
|
240 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
241 |
2696 | 242 status = status - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_LEVEL_200; |
243 status_line = &ngx_http_status_lines[status]; | |
244 len += ngx_http_status_lines[status].len; | |
245 | |
246 } else if (status >= NGX_HTTP_BAD_REQUEST | |
2700
aee784753144
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
2696
diff
changeset
|
247 && status < NGX_HTTP_LAST_LEVEL_400) |
2696 | 248 { |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
249 /* 4XX */ |
2696 | 250 status = status - NGX_HTTP_BAD_REQUEST |
251 + NGX_HTTP_LEVEL_200 | |
252 + NGX_HTTP_LEVEL_300; | |
253 | |
254 status_line = &ngx_http_status_lines[status]; | |
255 len += ngx_http_status_lines[status].len; | |
256 | |
257 } else if (status >= NGX_HTTP_INTERNAL_SERVER_ERROR | |
258 && status < NGX_HTTP_LAST_LEVEL_500) | |
259 { | |
260 /* 5XX */ | |
261 status = status - NGX_HTTP_INTERNAL_SERVER_ERROR | |
262 + NGX_HTTP_LEVEL_200 | |
263 + NGX_HTTP_LEVEL_300 | |
264 + NGX_HTTP_LEVEL_400; | |
265 | |
266 status_line = &ngx_http_status_lines[status]; | |
267 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
|
268 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
269 } else { |
2696 | 270 len += NGX_INT_T_LEN; |
271 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
|
272 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
273 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
274 |
1592 | 275 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
276 | |
509 | 277 if (r->headers_out.server == NULL) { |
1592 | 278 len += clcf->server_tokens ? sizeof(ngx_http_server_full_string) - 1: |
279 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
|
280 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
281 |
509 | 282 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
|
283 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
|
284 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
285 |
509 | 286 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
|
287 len += sizeof("Content-Type: ") - 1 |
509 | 288 + 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
|
289 |
657 | 290 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
291 && r->headers_out.charset.len) | |
292 { | |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
293 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
|
294 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
295 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
296 |
509 | 297 if (r->headers_out.content_length == NULL |
298 && r->headers_out.content_length_n >= 0) | |
299 { | |
300 len += sizeof("Content-Length: ") - 1 + NGX_OFF_T_LEN + 2; | |
301 } | |
302 | |
303 if (r->headers_out.last_modified == NULL | |
304 && r->headers_out.last_modified_time != -1) | |
305 { | |
306 len += sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1; | |
307 } | |
308 | |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
309 c = r->connection; |
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
310 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
311 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
|
312 && 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
|
313 && 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
|
314 { |
509 | 315 r->headers_out.location->hash = 0; |
316 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
317 if (clcf->server_name_in_redirect) { |
1811 | 318 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
319 host = cscf->server_name; | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
320 |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
321 } else if (r->headers_in.server.len) { |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
322 host = r->headers_in.server; |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
323 |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
324 } else { |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2197
diff
changeset
|
325 host.len = NGX_SOCKADDR_STRLEN; |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
326 host.data = addr; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
327 |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
328 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
|
329 return NGX_ERROR; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
330 } |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
331 } |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
332 |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
333 switch (c->local_sockaddr->sa_family) { |
2529 | 334 |
335 #if (NGX_HAVE_INET6) | |
336 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
|
337 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; |
2531 | 338 port = ntohs(sin6->sin6_port); |
2529 | 339 break; |
340 #endif | |
3483
192b727c2563
do not add a port in redirect if we listen on unix domain socket
Igor Sysoev <igor@sysoev.ru>
parents:
3462
diff
changeset
|
341 #if (NGX_HAVE_UNIX_DOMAIN) |
192b727c2563
do not add a port in redirect if we listen on unix domain socket
Igor Sysoev <igor@sysoev.ru>
parents:
3462
diff
changeset
|
342 case AF_UNIX: |
192b727c2563
do not add a port in redirect if we listen on unix domain socket
Igor Sysoev <igor@sysoev.ru>
parents:
3462
diff
changeset
|
343 port = 0; |
192b727c2563
do not add a port in redirect if we listen on unix domain socket
Igor Sysoev <igor@sysoev.ru>
parents:
3462
diff
changeset
|
344 break; |
192b727c2563
do not add a port in redirect if we listen on unix domain socket
Igor Sysoev <igor@sysoev.ru>
parents:
3462
diff
changeset
|
345 #endif |
2529 | 346 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
|
347 sin = (struct sockaddr_in *) c->local_sockaddr; |
2531 | 348 port = ntohs(sin->sin_port); |
2529 | 349 break; |
350 } | |
351 | |
2533 | 352 len += sizeof("Location: https://") - 1 |
353 + host.len | |
354 + r->headers_out.location->value.len + 2; | |
517 | 355 |
2533 | 356 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
|
357 |
2533 | 358 #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
|
359 if (c->ssl) |
2551 | 360 port = (port == 443) ? 0 : port; |
361 else | |
517 | 362 #endif |
2551 | 363 port = (port == 80) ? 0 : port; |
2768
e4a4c889694f
"port_in_redirect off" did not work
Igor Sysoev <igor@sysoev.ru>
parents:
2709
diff
changeset
|
364 |
e4a4c889694f
"port_in_redirect off" did not work
Igor Sysoev <igor@sysoev.ru>
parents:
2709
diff
changeset
|
365 } else { |
e4a4c889694f
"port_in_redirect off" did not work
Igor Sysoev <igor@sysoev.ru>
parents:
2709
diff
changeset
|
366 port = 0; |
2551 | 367 } |
517 | 368 |
2533 | 369 if (port) { |
370 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
|
371 } |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
372 |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
373 } else { |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
374 host.len = 0; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
375 host.data = NULL; |
2529 | 376 port = 0; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
377 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
10
diff
changeset
|
378 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
379 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
|
380 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
|
381 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
382 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
383 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
|
384 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
|
385 |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
386 /* |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
387 * 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
|
388 * 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
|
389 * 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
|
390 * 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
|
391 * 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
|
392 */ |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
393 |
473 | 394 if (clcf->keepalive_header) { |
477 | 395 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
|
396 } |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
397 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
398 } else { |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
399 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
|
400 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
401 |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
402 #if (NGX_HTTP_GZIP) |
3313 | 403 if (r->gzip_vary) { |
404 if (clcf->gzip_vary) { | |
405 len += sizeof("Vary: Accept-Encoding" CRLF) - 1; | |
406 | |
407 } else { | |
408 r->gzip_vary = 0; | |
409 } | |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
410 } |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
411 #endif |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
412 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
413 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
|
414 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
415 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
416 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
|
417 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
418 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
|
419 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
|
420 break; |
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 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
423 part = part->next; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
424 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
425 i = 0; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
426 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
427 |
509 | 428 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
|
429 continue; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
430 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
431 |
493 | 432 len += header[i].key.len + sizeof(": ") - 1 + header[i].value.len |
433 + 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
|
434 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
435 |
501 | 436 b = ngx_create_temp_buf(r->pool, len); |
437 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
|
438 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
|
439 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
440 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
441 /* "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
|
442 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
|
443 |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
444 /* status line */ |
2696 | 445 if (status_line) { |
446 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
|
447 |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
448 } else { |
2696 | 449 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
|
450 } |
493 | 451 *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
|
452 |
509 | 453 if (r->headers_out.server == NULL) { |
1592 | 454 if (clcf->server_tokens) { |
1594 | 455 p = (u_char *) ngx_http_server_full_string; |
1592 | 456 len = sizeof(ngx_http_server_full_string) - 1; |
457 | |
458 } else { | |
1594 | 459 p = (u_char *) ngx_http_server_string; |
1592 | 460 len = sizeof(ngx_http_server_string) - 1; |
461 } | |
462 | |
463 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
|
464 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
465 |
509 | 466 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
|
467 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
|
468 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
|
469 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
|
470 |
493 | 471 *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
|
472 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
473 |
509 | 474 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
|
475 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
|
476 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
|
477 p = b->last; |
573 | 478 b->last = ngx_copy(b->last, r->headers_out.content_type.data, |
479 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
|
480 |
657 | 481 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
482 && r->headers_out.charset.len) | |
483 { | |
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
|
484 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
|
485 sizeof("; charset=") - 1); |
573 | 486 b->last = ngx_copy(b->last, r->headers_out.charset.data, |
487 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
|
488 |
509 | 489 /* update r->headers_out.content_type for possible logging */ |
490 | |
491 r->headers_out.content_type.len = b->last - p; | |
492 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
|
493 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
494 |
493 | 495 *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
|
496 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
497 |
509 | 498 if (r->headers_out.content_length == NULL |
499 && r->headers_out.content_length_n >= 0) | |
500 { | |
501 b->last = ngx_sprintf(b->last, "Content-Length: %O" CRLF, | |
502 r->headers_out.content_length_n); | |
503 } | |
504 | |
505 if (r->headers_out.last_modified == NULL | |
506 && r->headers_out.last_modified_time != -1) | |
507 { | |
508 b->last = ngx_cpymem(b->last, "Last-Modified: ", | |
509 sizeof("Last-Modified: ") - 1); | |
510 b->last = ngx_http_time(b->last, r->headers_out.last_modified_time); | |
511 | |
512 *b->last++ = CR; *b->last++ = LF; | |
513 } | |
514 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
515 if (host.data) { |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
516 |
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
|
517 p = b->last + sizeof("Location: ") - 1; |
517 | 518 |
519 b->last = ngx_cpymem(b->last, "Location: http", | |
520 sizeof("Location: http") - 1); | |
521 | |
522 #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
|
523 if (c->ssl) { |
517 | 524 *b->last++ ='s'; |
525 } | |
526 #endif | |
527 | |
528 *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/'; | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
529 b->last = ngx_copy(b->last, host.data, host.len); |
517 | 530 |
2533 | 531 if (port) { |
532 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
|
533 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
534 |
573 | 535 b->last = ngx_copy(b->last, r->headers_out.location->value.data, |
536 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
|
537 |
509 | 538 /* update r->headers_out.location->value for possible logging */ |
539 | |
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
|
540 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
|
541 r->headers_out.location->value.data = p; |
3461
e51e8ec95b50
use a right "Location" header name, however, it did not harm,
Igor Sysoev <igor@sysoev.ru>
parents:
3331
diff
changeset
|
542 r->headers_out.location->key.len = sizeof("Location") - 1; |
e51e8ec95b50
use a right "Location" header name, however, it did not harm,
Igor Sysoev <igor@sysoev.ru>
parents:
3331
diff
changeset
|
543 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
|
544 |
493 | 545 *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
|
546 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
10
diff
changeset
|
547 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
548 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
|
549 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
|
550 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
|
551 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
552 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
553 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
|
554 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
|
555 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
|
556 |
473 | 557 if (clcf->keepalive_header) { |
455 | 558 b->last = ngx_sprintf(b->last, "Keep-Alive: timeout=%T" CRLF, |
559 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
|
560 } |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
561 |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
562 } 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
|
563 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
|
564 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
|
565 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
566 |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
567 #if (NGX_HTTP_GZIP) |
3313 | 568 if (r->gzip_vary) { |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
569 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
|
570 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
|
571 } |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
572 #endif |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
573 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
574 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
|
575 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
576 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
577 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
|
578 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
579 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
|
580 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
|
581 break; |
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 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
584 part = part->next; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
585 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
586 i = 0; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
587 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
588 |
509 | 589 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
|
590 continue; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
591 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
592 |
573 | 593 b->last = ngx_copy(b->last, header[i].key.data, header[i].key.len); |
2024 | 594 *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
|
595 |
573 | 596 b->last = ngx_copy(b->last, header[i].value.data, header[i].value.len); |
493 | 597 *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
|
598 } |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
599 |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
600 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
2709 | 601 "%*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
|
602 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
603 /* the end of HTTP header */ |
493 | 604 *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
|
605 |
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
|
606 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
|
607 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
608 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
|
609 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
|
610 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
611 |
501 | 612 out.buf = b; |
613 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
|
614 |
501 | 615 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
|
616 } |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
617 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
618 |
493 | 619 static ngx_int_t |
681 | 620 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
|
621 { |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
622 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
|
623 |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
624 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
|
625 } |