Mercurial > hg > nginx-quic
annotate src/http/ngx_http_header_filter_module.c @ 8119:d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Sun, 27 Sep 2020 23:21:11 +0300 |
parents | 8801ff7d58e1 |
children | 38c0898b6df7 96ae8e57b3dd |
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 |
4412 | 4 * Copyright (C) Nginx, Inc. |
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
|
5 */ |
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
|
6 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
7 |
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
8 #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
|
9 #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
|
10 #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
|
11 #include <nginx.h> |
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
12 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 |
681 | 14 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
|
15 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
|
16 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
17 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
18 static ngx_http_module_t ngx_http_header_filter_module_ctx = { |
509 | 19 NULL, /* preconfiguration */ |
681 | 20 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
|
21 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
22 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
|
23 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
|
24 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
25 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
|
26 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
|
27 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
28 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
|
29 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
|
30 }; |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
31 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
33 ngx_module_t ngx_http_header_filter_module = { |
509 | 34 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
|
35 &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
|
36 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
|
37 NGX_HTTP_MODULE, /* module type */ |
541 | 38 NULL, /* init master */ |
681 | 39 NULL, /* init module */ |
541 | 40 NULL, /* init process */ |
41 NULL, /* init thread */ | |
42 NULL, /* exit thread */ | |
43 NULL, /* exit process */ | |
44 NULL, /* exit master */ | |
45 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
|
46 }; |
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
47 |
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
48 |
6885
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
49 static u_char ngx_http_server_string[] = "Server: nginx" CRLF; |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
50 static u_char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF; |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
51 static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
52 |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
53 |
509 | 54 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
|
55 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
56 ngx_string("200 OK"), |
633 | 57 ngx_string("201 Created"), |
3604 | 58 ngx_string("202 Accepted"), |
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, /* "203 Non-Authoritative Information" */ |
511 | 60 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
|
61 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
|
62 ngx_string("206 Partial Content"), |
499 | 63 |
64 /* 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
|
65 |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
66 #define NGX_HTTP_LAST_2XX 207 |
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
67 #define NGX_HTTP_OFF_3XX (NGX_HTTP_LAST_2XX - 200) |
499 | 68 |
69 /* 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
|
70 |
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
71 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
|
72 ngx_string("302 Moved Temporarily"), |
3631 | 73 ngx_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
|
74 ngx_string("304 Not Modified"), |
4491
d11f86a16e3b
Added support for the 307 Temporary Redirect.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
75 ngx_null_string, /* "305 Use Proxy" */ |
d11f86a16e3b
Added support for the 307 Temporary Redirect.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
76 ngx_null_string, /* "306 unused" */ |
d11f86a16e3b
Added support for the 307 Temporary Redirect.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
77 ngx_string("307 Temporary Redirect"), |
6977
be5cfa918bfc
Added support for the "308 Permanent Redirect" (ticket #877).
Simon Leblanc <contact@leblanc-simon.eu>
parents:
6965
diff
changeset
|
78 ngx_string("308 Permanent Redirect"), |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
79 |
6977
be5cfa918bfc
Added support for the "308 Permanent Redirect" (ticket #877).
Simon Leblanc <contact@leblanc-simon.eu>
parents:
6965
diff
changeset
|
80 #define NGX_HTTP_LAST_3XX 309 |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
81 #define NGX_HTTP_OFF_4XX (NGX_HTTP_LAST_3XX - 301 + NGX_HTTP_OFF_3XX) |
499 | 82 |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
83 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
|
84 ngx_string("401 Unauthorized"), |
499 | 85 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
|
86 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
|
87 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
|
88 ngx_string("405 Not Allowed"), |
499 | 89 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
|
90 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
|
91 ngx_string("408 Request Time-out"), |
663 | 92 ngx_string("409 Conflict"), |
499 | 93 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
|
94 ngx_string("411 Length Required"), |
1057 | 95 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
|
96 ngx_string("413 Request Entity Too Large"), |
5369
907f01a2a7c0
Return reason phrase for 414.
Valentin Bartenev <vbart@nginx.com>
parents:
5364
diff
changeset
|
97 ngx_string("414 Request-URI Too Large"), |
637 | 98 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
|
99 ngx_string("416 Requested Range Not Satisfiable"), |
6556
654d2dae97d3
HTTP/2: the "421 Misdirected Request" response (closes #848).
Valentin Bartenev <vbart@nginx.com>
parents:
6451
diff
changeset
|
100 ngx_null_string, /* "417 Expectation Failed" */ |
654d2dae97d3
HTTP/2: the "421 Misdirected Request" response (closes #848).
Valentin Bartenev <vbart@nginx.com>
parents:
6451
diff
changeset
|
101 ngx_null_string, /* "418 unused" */ |
654d2dae97d3
HTTP/2: the "421 Misdirected Request" response (closes #848).
Valentin Bartenev <vbart@nginx.com>
parents:
6451
diff
changeset
|
102 ngx_null_string, /* "419 unused" */ |
654d2dae97d3
HTTP/2: the "421 Misdirected Request" response (closes #848).
Valentin Bartenev <vbart@nginx.com>
parents:
6451
diff
changeset
|
103 ngx_null_string, /* "420 unused" */ |
654d2dae97d3
HTTP/2: the "421 Misdirected Request" response (closes #848).
Valentin Bartenev <vbart@nginx.com>
parents:
6451
diff
changeset
|
104 ngx_string("421 Misdirected Request"), |
6965
3ef4cadfad7f
Added support for "429 Too Many Requests" response (RFC6585).
Piotr Sikora <piotrsikora@google.com>
parents:
6885
diff
changeset
|
105 ngx_null_string, /* "422 Unprocessable Entity" */ |
3ef4cadfad7f
Added support for "429 Too Many Requests" response (RFC6585).
Piotr Sikora <piotrsikora@google.com>
parents:
6885
diff
changeset
|
106 ngx_null_string, /* "423 Locked" */ |
3ef4cadfad7f
Added support for "429 Too Many Requests" response (RFC6585).
Piotr Sikora <piotrsikora@google.com>
parents:
6885
diff
changeset
|
107 ngx_null_string, /* "424 Failed Dependency" */ |
3ef4cadfad7f
Added support for "429 Too Many Requests" response (RFC6585).
Piotr Sikora <piotrsikora@google.com>
parents:
6885
diff
changeset
|
108 ngx_null_string, /* "425 unused" */ |
3ef4cadfad7f
Added support for "429 Too Many Requests" response (RFC6585).
Piotr Sikora <piotrsikora@google.com>
parents:
6885
diff
changeset
|
109 ngx_null_string, /* "426 Upgrade Required" */ |
3ef4cadfad7f
Added support for "429 Too Many Requests" response (RFC6585).
Piotr Sikora <piotrsikora@google.com>
parents:
6885
diff
changeset
|
110 ngx_null_string, /* "427 unused" */ |
3ef4cadfad7f
Added support for "429 Too Many Requests" response (RFC6585).
Piotr Sikora <piotrsikora@google.com>
parents:
6885
diff
changeset
|
111 ngx_null_string, /* "428 Precondition Required" */ |
3ef4cadfad7f
Added support for "429 Too Many Requests" response (RFC6585).
Piotr Sikora <piotrsikora@google.com>
parents:
6885
diff
changeset
|
112 ngx_string("429 Too Many Requests"), |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
113 |
6965
3ef4cadfad7f
Added support for "429 Too Many Requests" response (RFC6585).
Piotr Sikora <piotrsikora@google.com>
parents:
6885
diff
changeset
|
114 #define NGX_HTTP_LAST_4XX 430 |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
115 #define NGX_HTTP_OFF_5XX (NGX_HTTP_LAST_4XX - 400 + NGX_HTTP_OFF_4XX) |
499 | 116 |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
117 ngx_string("500 Internal Server Error"), |
4920
812c4765c954
Request body: fixed "501 Not Implemented" error handling.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4698
diff
changeset
|
118 ngx_string("501 Not Implemented"), |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
64
diff
changeset
|
119 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
|
120 ngx_string("503 Service Temporarily Unavailable"), |
637 | 121 ngx_string("504 Gateway Time-out"), |
6993
8801ff7d58e1
Don't pretend we support HTTP major versions >1 as HTTP/1.1.
Ruslan Ermilov <ru@nginx.com>
parents:
6977
diff
changeset
|
122 ngx_string("505 HTTP Version Not Supported"), |
637 | 123 ngx_null_string, /* "506 Variant Also Negotiates" */ |
124 ngx_string("507 Insufficient Storage"), | |
6556
654d2dae97d3
HTTP/2: the "421 Misdirected Request" response (closes #848).
Valentin Bartenev <vbart@nginx.com>
parents:
6451
diff
changeset
|
125 |
499 | 126 /* ngx_null_string, */ /* "508 unused" */ |
127 /* ngx_null_string, */ /* "509 unused" */ | |
128 /* ngx_null_string, */ /* "510 Not Extended" */ | |
2696 | 129 |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
130 #define NGX_HTTP_LAST_5XX 508 |
2696 | 131 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
132 }; |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
133 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
134 |
569 | 135 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
|
136 { 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
|
137 { 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
|
138 { ngx_string("Content-Length"), |
499 | 139 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
|
140 { ngx_string("Content-Encoding"), |
499 | 141 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
|
142 { 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
|
143 { ngx_string("Last-Modified"), |
499 | 144 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
|
145 { ngx_string("Accept-Ranges"), |
499 | 146 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
|
147 { 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
|
148 { ngx_string("Cache-Control"), |
499 | 149 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
|
150 { 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
|
151 |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
152 { 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
|
153 }; |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
154 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
155 |
493 | 156 static ngx_int_t |
157 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
|
158 { |
429
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
159 u_char *p; |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
160 size_t len; |
6451
155871d773cc
Backed out server_tokens changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6449
diff
changeset
|
161 ngx_str_t host, *status_line; |
681 | 162 ngx_buf_t *b; |
2529 | 163 ngx_uint_t status, i, port; |
501 | 164 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
|
165 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
|
166 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
|
167 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
|
168 ngx_http_core_loc_conf_t *clcf; |
1811 | 169 ngx_http_core_srv_conf_t *cscf; |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2197
diff
changeset
|
170 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
|
171 |
3662 | 172 if (r->header_sent) { |
173 return NGX_OK; | |
174 } | |
175 | |
667 | 176 r->header_sent = 1; |
177 | |
3331
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
178 if (r != r->main) { |
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
179 return NGX_OK; |
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
180 } |
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
181 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
182 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
|
183 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
|
184 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
185 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
186 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
|
187 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
|
188 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
189 |
432
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
190 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
|
191 if (r->headers_out.status != NGX_HTTP_OK |
511 | 192 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT |
193 && 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
|
194 { |
11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
429
diff
changeset
|
195 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
|
196 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
|
197 } |
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 |
493 | 200 len = sizeof("HTTP/1.x ") - 1 + sizeof(CRLF) - 1 |
201 /* the end of the header */ | |
202 + sizeof(CRLF) - 1; | |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
203 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
204 /* status line */ |
452 | 205 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
206 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
|
207 len += r->headers_out.status_line.len; |
2696 | 208 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
|
209 #if (NGX_SUPPRESS_WARN) |
2696 | 210 status = 0; |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
47
diff
changeset
|
211 #endif |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
212 |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
213 } else { |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
177
diff
changeset
|
214 |
2696 | 215 status = r->headers_out.status; |
216 | |
217 if (status >= NGX_HTTP_OK | |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
218 && status < NGX_HTTP_LAST_2XX) |
2696 | 219 { |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
220 /* 2XX */ |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 |
2696 | 222 if (status == NGX_HTTP_NO_CONTENT) { |
511 | 223 r->header_only = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3483
diff
changeset
|
224 ngx_str_null(&r->headers_out.content_type); |
511 | 225 r->headers_out.last_modified_time = -1; |
226 r->headers_out.last_modified = NULL; | |
227 r->headers_out.content_length = NULL; | |
228 r->headers_out.content_length_n = -1; | |
229 } | |
230 | |
2696 | 231 status -= NGX_HTTP_OK; |
232 status_line = &ngx_http_status_lines[status]; | |
233 len += ngx_http_status_lines[status].len; | |
234 | |
235 } else if (status >= NGX_HTTP_MOVED_PERMANENTLY | |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
236 && status < NGX_HTTP_LAST_3XX) |
2696 | 237 { |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
238 /* 3XX */ |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
239 |
2696 | 240 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
|
241 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
|
242 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
243 |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
244 status = status - NGX_HTTP_MOVED_PERMANENTLY + NGX_HTTP_OFF_3XX; |
2696 | 245 status_line = &ngx_http_status_lines[status]; |
246 len += ngx_http_status_lines[status].len; | |
247 | |
248 } else if (status >= NGX_HTTP_BAD_REQUEST | |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
249 && status < NGX_HTTP_LAST_4XX) |
2696 | 250 { |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
71
diff
changeset
|
251 /* 4XX */ |
2696 | 252 status = status - NGX_HTTP_BAD_REQUEST |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
253 + NGX_HTTP_OFF_4XX; |
2696 | 254 |
255 status_line = &ngx_http_status_lines[status]; | |
256 len += ngx_http_status_lines[status].len; | |
257 | |
258 } else if (status >= NGX_HTTP_INTERNAL_SERVER_ERROR | |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
259 && status < NGX_HTTP_LAST_5XX) |
2696 | 260 { |
261 /* 5XX */ | |
262 status = status - NGX_HTTP_INTERNAL_SERVER_ERROR | |
4337
68b28a88749d
Renamed some constants to improve readability, no functional changes.
Ruslan Ermilov <ru@nginx.com>
parents:
3662
diff
changeset
|
263 + NGX_HTTP_OFF_5XX; |
2696 | 264 |
265 status_line = &ngx_http_status_lines[status]; | |
266 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
|
267 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
268 } else { |
5382
e8d24b6d7f73
Fixed response line formatting with empty reason phrase.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5369
diff
changeset
|
269 len += NGX_INT_T_LEN + 1 /* SP */; |
2696 | 270 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
|
271 } |
5364
941c5e3561ed
Fixed incorrect response line on "return 203".
Maxim Dounin <mdounin@mdounin.ru>
parents:
5072
diff
changeset
|
272 |
941c5e3561ed
Fixed incorrect response line on "return 203".
Maxim Dounin <mdounin@mdounin.ru>
parents:
5072
diff
changeset
|
273 if (status_line && status_line->len == 0) { |
941c5e3561ed
Fixed incorrect response line on "return 203".
Maxim Dounin <mdounin@mdounin.ru>
parents:
5072
diff
changeset
|
274 status = r->headers_out.status; |
5382
e8d24b6d7f73
Fixed response line formatting with empty reason phrase.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5369
diff
changeset
|
275 len += NGX_INT_T_LEN + 1 /* SP */; |
5364
941c5e3561ed
Fixed incorrect response line on "return 203".
Maxim Dounin <mdounin@mdounin.ru>
parents:
5072
diff
changeset
|
276 status_line = NULL; |
941c5e3561ed
Fixed incorrect response line on "return 203".
Maxim Dounin <mdounin@mdounin.ru>
parents:
5072
diff
changeset
|
277 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
278 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
279 |
1592 | 280 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
281 | |
509 | 282 if (r->headers_out.server == NULL) { |
6885
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
283 if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) { |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
284 len += sizeof(ngx_http_server_full_string) - 1; |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
285 |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
286 } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) { |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
287 len += sizeof(ngx_http_server_build_string) - 1; |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
288 |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
289 } else { |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
290 len += sizeof(ngx_http_server_string) - 1; |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
291 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
292 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
293 |
509 | 294 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
|
295 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
|
296 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
297 |
509 | 298 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
|
299 len += sizeof("Content-Type: ") - 1 |
509 | 300 + 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
|
301 |
657 | 302 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
303 && r->headers_out.charset.len) | |
304 { | |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
305 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
|
306 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
307 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
308 |
509 | 309 if (r->headers_out.content_length == NULL |
310 && r->headers_out.content_length_n >= 0) | |
311 { | |
312 len += sizeof("Content-Length: ") - 1 + NGX_OFF_T_LEN + 2; | |
313 } | |
314 | |
315 if (r->headers_out.last_modified == NULL | |
316 && r->headers_out.last_modified_time != -1) | |
317 { | |
318 len += sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1; | |
319 } | |
320 | |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
321 c = r->connection; |
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
322 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
323 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
|
324 && r->headers_out.location->value.len |
6852
d15172ebb400
Core: relative redirects (closes #1000).
Ruslan Ermilov <ru@nginx.com>
parents:
6593
diff
changeset
|
325 && r->headers_out.location->value.data[0] == '/' |
d15172ebb400
Core: relative redirects (closes #1000).
Ruslan Ermilov <ru@nginx.com>
parents:
6593
diff
changeset
|
326 && clcf->absolute_redirect) |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
327 { |
509 | 328 r->headers_out.location->hash = 0; |
329 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
330 if (clcf->server_name_in_redirect) { |
1811 | 331 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
332 host = cscf->server_name; | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
333 |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
334 } else if (r->headers_in.server.len) { |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
335 host = r->headers_in.server; |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
336 |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
337 } else { |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2197
diff
changeset
|
338 host.len = NGX_SOCKADDR_STRLEN; |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
339 host.data = addr; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
340 |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
341 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
|
342 return NGX_ERROR; |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
343 } |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
344 } |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
345 |
6593
b3b7e33083ac
Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.
Roman Arutyunyan <arut@nginx.com>
parents:
6556
diff
changeset
|
346 port = ngx_inet_get_port(c->local_sockaddr); |
2529 | 347 |
2533 | 348 len += sizeof("Location: https://") - 1 |
349 + host.len | |
350 + r->headers_out.location->value.len + 2; | |
517 | 351 |
2533 | 352 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
|
353 |
2533 | 354 #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
|
355 if (c->ssl) |
2551 | 356 port = (port == 443) ? 0 : port; |
357 else | |
517 | 358 #endif |
2551 | 359 port = (port == 80) ? 0 : port; |
2768
e4a4c889694f
"port_in_redirect off" did not work
Igor Sysoev <igor@sysoev.ru>
parents:
2709
diff
changeset
|
360 |
e4a4c889694f
"port_in_redirect off" did not work
Igor Sysoev <igor@sysoev.ru>
parents:
2709
diff
changeset
|
361 } else { |
e4a4c889694f
"port_in_redirect off" did not work
Igor Sysoev <igor@sysoev.ru>
parents:
2709
diff
changeset
|
362 port = 0; |
2551 | 363 } |
517 | 364 |
2533 | 365 if (port) { |
366 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
|
367 } |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
368 |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
369 } else { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3483
diff
changeset
|
370 ngx_str_null(&host); |
2529 | 371 port = 0; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
372 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
10
diff
changeset
|
373 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
374 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
|
375 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
|
376 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
377 |
5072
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4920
diff
changeset
|
378 if (r->headers_out.status == NGX_HTTP_SWITCHING_PROTOCOLS) { |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4920
diff
changeset
|
379 len += sizeof("Connection: upgrade" CRLF) - 1; |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4920
diff
changeset
|
380 |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4920
diff
changeset
|
381 } else 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
|
382 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
|
383 |
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 * 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
|
386 * 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
|
387 * 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
|
388 * 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
|
389 * 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
|
390 */ |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
391 |
473 | 392 if (clcf->keepalive_header) { |
477 | 393 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
|
394 } |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
395 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
396 } else { |
4698
4c415af7dbc2
Fixed a harmless error in spelling of "Connection: close" when computing
Ruslan Ermilov <ru@nginx.com>
parents:
4637
diff
changeset
|
397 len += sizeof("Connection: close" CRLF) - 1; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
398 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
399 |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
400 #if (NGX_HTTP_GZIP) |
3313 | 401 if (r->gzip_vary) { |
402 if (clcf->gzip_vary) { | |
403 len += sizeof("Vary: Accept-Encoding" CRLF) - 1; | |
404 | |
405 } else { | |
406 r->gzip_vary = 0; | |
407 } | |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
408 } |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
409 #endif |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
410 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
411 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
|
412 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
413 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
414 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
|
415 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
416 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
|
417 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
|
418 break; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
419 } |
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 part = part->next; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
422 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
423 i = 0; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
424 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
425 |
509 | 426 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
|
427 continue; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
428 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
429 |
493 | 430 len += header[i].key.len + sizeof(": ") - 1 + header[i].value.len |
431 + 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
|
432 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
433 |
501 | 434 b = ngx_create_temp_buf(r->pool, len); |
435 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
|
436 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
|
437 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
438 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
439 /* "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
|
440 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
|
441 |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
442 /* status line */ |
2696 | 443 if (status_line) { |
444 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
|
445 |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
446 } else { |
5382
e8d24b6d7f73
Fixed response line formatting with empty reason phrase.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5369
diff
changeset
|
447 b->last = ngx_sprintf(b->last, "%03ui ", status); |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
448 } |
493 | 449 *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
|
450 |
6449
e5076b96fd01
Reconsidered server_tokens with an empty value.
Ruslan Ermilov <ru@nginx.com>
parents:
6433
diff
changeset
|
451 if (r->headers_out.server == NULL) { |
6885
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
452 if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) { |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
453 p = ngx_http_server_full_string; |
6451
155871d773cc
Backed out server_tokens changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6449
diff
changeset
|
454 len = sizeof(ngx_http_server_full_string) - 1; |
155871d773cc
Backed out server_tokens changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6449
diff
changeset
|
455 |
6885
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
456 } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) { |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
457 p = ngx_http_server_build_string; |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
458 len = sizeof(ngx_http_server_build_string) - 1; |
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
459 |
6451
155871d773cc
Backed out server_tokens changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6449
diff
changeset
|
460 } else { |
6885
25203fc377fb
Implemented the "server_tokens build" option.
Ruslan Ermilov <ru@nginx.com>
parents:
6852
diff
changeset
|
461 p = ngx_http_server_string; |
6451
155871d773cc
Backed out server_tokens changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6449
diff
changeset
|
462 len = sizeof(ngx_http_server_string) - 1; |
155871d773cc
Backed out server_tokens changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6449
diff
changeset
|
463 } |
155871d773cc
Backed out server_tokens changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6449
diff
changeset
|
464 |
155871d773cc
Backed out server_tokens changes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6449
diff
changeset
|
465 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
|
466 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
467 |
509 | 468 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
|
469 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
|
470 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
|
471 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
|
472 |
493 | 473 *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
|
474 } |
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
475 |
509 | 476 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
|
477 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
|
478 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
|
479 p = b->last; |
573 | 480 b->last = ngx_copy(b->last, r->headers_out.content_type.data, |
481 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
|
482 |
657 | 483 if (r->headers_out.content_type_len == r->headers_out.content_type.len |
484 && r->headers_out.charset.len) | |
485 { | |
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
|
486 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
|
487 sizeof("; charset=") - 1); |
573 | 488 b->last = ngx_copy(b->last, r->headers_out.charset.data, |
489 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
|
490 |
509 | 491 /* update r->headers_out.content_type for possible logging */ |
492 | |
493 r->headers_out.content_type.len = b->last - p; | |
494 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
|
495 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
496 |
493 | 497 *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
|
498 } |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
499 |
509 | 500 if (r->headers_out.content_length == NULL |
501 && r->headers_out.content_length_n >= 0) | |
502 { | |
503 b->last = ngx_sprintf(b->last, "Content-Length: %O" CRLF, | |
504 r->headers_out.content_length_n); | |
505 } | |
506 | |
507 if (r->headers_out.last_modified == NULL | |
508 && r->headers_out.last_modified_time != -1) | |
509 { | |
510 b->last = ngx_cpymem(b->last, "Last-Modified: ", | |
511 sizeof("Last-Modified: ") - 1); | |
512 b->last = ngx_http_time(b->last, r->headers_out.last_modified_time); | |
513 | |
514 *b->last++ = CR; *b->last++ = LF; | |
515 } | |
516 | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
517 if (host.data) { |
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
518 |
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
|
519 p = b->last + sizeof("Location: ") - 1; |
517 | 520 |
521 b->last = ngx_cpymem(b->last, "Location: http", | |
522 sizeof("Location: http") - 1); | |
523 | |
524 #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
|
525 if (c->ssl) { |
517 | 526 *b->last++ ='s'; |
527 } | |
528 #endif | |
529 | |
530 *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/'; | |
1804
d457a1576532
several changes in server_name:
Igor Sysoev <igor@sysoev.ru>
parents:
1774
diff
changeset
|
531 b->last = ngx_copy(b->last, host.data, host.len); |
517 | 532 |
2533 | 533 if (port) { |
534 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
|
535 } |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
536 |
573 | 537 b->last = ngx_copy(b->last, r->headers_out.location->value.data, |
538 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
|
539 |
509 | 540 /* update r->headers_out.location->value for possible logging */ |
541 | |
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
|
542 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
|
543 r->headers_out.location->value.data = p; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3483
diff
changeset
|
544 ngx_str_set(&r->headers_out.location->key, "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
|
545 |
493 | 546 *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
|
547 } |
13
2aba961a1d34
nginx-0.0.1-2002-09-16-19:01:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
10
diff
changeset
|
548 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
549 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
|
550 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
|
551 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
|
552 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
553 |
5072
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4920
diff
changeset
|
554 if (r->headers_out.status == NGX_HTTP_SWITCHING_PROTOCOLS) { |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4920
diff
changeset
|
555 b->last = ngx_cpymem(b->last, "Connection: upgrade" CRLF, |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4920
diff
changeset
|
556 sizeof("Connection: upgrade" CRLF) - 1); |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4920
diff
changeset
|
557 |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4920
diff
changeset
|
558 } else 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
|
559 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
|
560 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
|
561 |
473 | 562 if (clcf->keepalive_header) { |
455 | 563 b->last = ngx_sprintf(b->last, "Keep-Alive: timeout=%T" CRLF, |
564 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
|
565 } |
694cd6cdb714
nginx-0.0.11-2004-09-17-20:07:35 import
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
566 |
64
34d647deb1da
nginx-0.0.1-2003-03-04-09:33:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
63
diff
changeset
|
567 } 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
|
568 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
|
569 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
|
570 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
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 #if (NGX_HTTP_GZIP) |
3313 | 573 if (r->gzip_vary) { |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
574 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
|
575 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
|
576 } |
2081
8488178092f2
nginx could not be build without gzip, introduced in r2052
Igor Sysoev <igor@sysoev.ru>
parents:
2051
diff
changeset
|
577 #endif |
2051
115e6f029fcc
"gzip_vary on" always sends "Vary: Accept-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
2024
diff
changeset
|
578 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
579 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
|
580 header = part->elts; |
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 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
|
583 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
584 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
|
585 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
|
586 break; |
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 |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
589 part = part->next; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
590 header = part->elts; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
591 i = 0; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
592 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
393
diff
changeset
|
593 |
509 | 594 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
|
595 continue; |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
596 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
19
diff
changeset
|
597 |
573 | 598 b->last = ngx_copy(b->last, header[i].key.data, header[i].key.len); |
2024 | 599 *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
|
600 |
573 | 601 b->last = ngx_copy(b->last, header[i].value.data, header[i].value.len); |
493 | 602 *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
|
603 } |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
604 |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2768
diff
changeset
|
605 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
2709 | 606 "%*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
|
607 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
608 /* the end of HTTP header */ |
493 | 609 *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
|
610 |
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
|
611 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
|
612 |
41
59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
613 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
|
614 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
|
615 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
616 |
501 | 617 out.buf = b; |
618 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
|
619 |
501 | 620 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
|
621 } |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
622 |
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
623 |
493 | 624 static ngx_int_t |
681 | 625 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
|
626 { |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
627 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
|
628 |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
629 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
|
630 } |