Mercurial > hg > nginx
annotate src/http/modules/perl/nginx.pm @ 7355:b64adc956643
Rewrite: removed r->err_status special handling (ticket #1634).
Trying to look into r->err_status in the "return" directive
makes it behave differently than real errors generated in other
parts of the code, and is an endless source of various problems.
This behaviour was introduced in 726:7b71936d5299 (0.4.4) with
the comment "fix: "return" always overrode "error_page" response code".
It is not clear if there were any real cases this was expected to fix,
but there are several cases which are broken due to this change, some
previously fixed (4147:7f64de1cc2c0).
In ticket #1634, the problem is that when r->err_status is set to
a non-special status code, it is not possible to return a response
by simply returning r->err_status. If this is the case, the only
option is to return script's e->status instead. An example
configuration:
location / {
error_page 404 =200 /err502;
return 404;
}
location = /err502 {
return 502;
}
After the change, such a configuration will properly return
standard 502 error, much like it happens when a 502 error is
generated by proxy_pass.
This also fixes the following configuration to properly close
connection as clearly requested by "return 444":
location / {
error_page 404 /close;
return 404;
}
location = /close {
return 444;
}
Previously, this required "error_page 404 = /close;" to work
as intended.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 21 Sep 2018 15:59:33 +0300 |
parents | be5cfa918bfc |
children | 985b0bda403c |
rev | line source |
---|---|
599 | 1 package nginx; |
2 | |
3 use 5.006001; | |
4 use strict; | |
5 use warnings; | |
6 | |
7 require Exporter; | |
8 | |
9 our @ISA = qw(Exporter); | |
10 | |
11 our @EXPORT = qw( | |
12 OK | |
13 DECLINED | |
914 | 14 |
599 | 15 HTTP_OK |
914 | 16 HTTP_CREATED |
3604 | 17 HTTP_ACCEPTED |
914 | 18 HTTP_NO_CONTENT |
19 HTTP_PARTIAL_CONTENT | |
20 | |
21 HTTP_MOVED_PERMANENTLY | |
22 HTTP_MOVED_TEMPORARILY | |
599 | 23 HTTP_REDIRECT |
4491
d11f86a16e3b
Added support for the 307 Temporary Redirect.
Ruslan Ermilov <ru@nginx.com>
parents:
4483
diff
changeset
|
24 HTTP_SEE_OTHER |
914 | 25 HTTP_NOT_MODIFIED |
4491
d11f86a16e3b
Added support for the 307 Temporary Redirect.
Ruslan Ermilov <ru@nginx.com>
parents:
4483
diff
changeset
|
26 HTTP_TEMPORARY_REDIRECT |
6977
be5cfa918bfc
Added support for the "308 Permanent Redirect" (ticket #877).
Simon Leblanc <contact@leblanc-simon.eu>
parents:
5146
diff
changeset
|
27 HTTP_PERMANENT_REDIRECT |
914 | 28 |
29 HTTP_BAD_REQUEST | |
30 HTTP_UNAUTHORIZED | |
31 HTTP_PAYMENT_REQUIRED | |
32 HTTP_FORBIDDEN | |
599 | 33 HTTP_NOT_FOUND |
914 | 34 HTTP_NOT_ALLOWED |
35 HTTP_NOT_ACCEPTABLE | |
36 HTTP_REQUEST_TIME_OUT | |
37 HTTP_CONFLICT | |
38 HTTP_GONE | |
39 HTTP_LENGTH_REQUIRED | |
40 HTTP_REQUEST_ENTITY_TOO_LARGE | |
41 HTTP_REQUEST_URI_TOO_LARGE | |
42 HTTP_UNSUPPORTED_MEDIA_TYPE | |
43 HTTP_RANGE_NOT_SATISFIABLE | |
44 | |
45 HTTP_INTERNAL_SERVER_ERROR | |
599 | 46 HTTP_SERVER_ERROR |
914 | 47 HTTP_NOT_IMPLEMENTED |
48 HTTP_BAD_GATEWAY | |
49 HTTP_SERVICE_UNAVAILABLE | |
50 HTTP_GATEWAY_TIME_OUT | |
51 HTTP_INSUFFICIENT_STORAGE | |
599 | 52 ); |
53 | |
5146
f45b83d20cfb
Simplified nginx version maintenance.
Ruslan Ermilov <ru@nginx.com>
parents:
5140
diff
changeset
|
54 our $VERSION = '%%VERSION%%'; |
599 | 55 |
56 require XSLoader; | |
57 XSLoader::load('nginx', $VERSION); | |
58 | |
59 # Preloaded methods go here. | |
60 | |
914 | 61 use constant OK => 0; |
62 use constant DECLINED => -5; | |
63 | |
64 use constant HTTP_OK => 200; | |
65 use constant HTTP_CREATED => 201; | |
3604 | 66 use constant HTTP_ACCEPTED => 202; |
914 | 67 use constant HTTP_NO_CONTENT => 204; |
68 use constant HTTP_PARTIAL_CONTENT => 206; | |
69 | |
70 use constant HTTP_MOVED_PERMANENTLY => 301; | |
71 use constant HTTP_MOVED_TEMPORARILY => 302; | |
72 use constant HTTP_REDIRECT => 302; | |
4491
d11f86a16e3b
Added support for the 307 Temporary Redirect.
Ruslan Ermilov <ru@nginx.com>
parents:
4483
diff
changeset
|
73 use constant HTTP_SEE_OTHER => 303; |
914 | 74 use constant HTTP_NOT_MODIFIED => 304; |
4491
d11f86a16e3b
Added support for the 307 Temporary Redirect.
Ruslan Ermilov <ru@nginx.com>
parents:
4483
diff
changeset
|
75 use constant HTTP_TEMPORARY_REDIRECT => 307; |
6977
be5cfa918bfc
Added support for the "308 Permanent Redirect" (ticket #877).
Simon Leblanc <contact@leblanc-simon.eu>
parents:
5146
diff
changeset
|
76 use constant HTTP_PERMANENT_REDIRECT => 308; |
599 | 77 |
914 | 78 use constant HTTP_BAD_REQUEST => 400; |
79 use constant HTTP_UNAUTHORIZED => 401; | |
80 use constant HTTP_PAYMENT_REQUIRED => 402; | |
81 use constant HTTP_FORBIDDEN => 403; | |
82 use constant HTTP_NOT_FOUND => 404; | |
83 use constant HTTP_NOT_ALLOWED => 405; | |
84 use constant HTTP_NOT_ACCEPTABLE => 406; | |
85 use constant HTTP_REQUEST_TIME_OUT => 408; | |
86 use constant HTTP_CONFLICT => 409; | |
87 use constant HTTP_GONE => 410; | |
88 use constant HTTP_LENGTH_REQUIRED => 411; | |
89 use constant HTTP_REQUEST_ENTITY_TOO_LARGE => 413; | |
90 use constant HTTP_REQUEST_URI_TOO_LARGE => 414; | |
91 use constant HTTP_UNSUPPORTED_MEDIA_TYPE => 415; | |
92 use constant HTTP_RANGE_NOT_SATISFIABLE => 416; | |
93 | |
94 use constant HTTP_INTERNAL_SERVER_ERROR => 500; | |
95 use constant HTTP_SERVER_ERROR => 500; | |
96 use constant HTTP_NOT_IMPLEMENTED => 501; | |
97 use constant HTTP_BAD_GATEWAY => 502; | |
98 use constant HTTP_SERVICE_UNAVAILABLE => 503; | |
99 use constant HTTP_GATEWAY_TIME_OUT => 504; | |
100 use constant HTTP_INSUFFICIENT_STORAGE => 507; | |
599 | 101 |
102 | |
1178
a77f6980de50
rename $r->rflush to $r->flush
Igor Sysoev <igor@sysoev.ru>
parents:
1177
diff
changeset
|
103 sub rflush { |
a77f6980de50
rename $r->rflush to $r->flush
Igor Sysoev <igor@sysoev.ru>
parents:
1177
diff
changeset
|
104 my $r = shift; |
a77f6980de50
rename $r->rflush to $r->flush
Igor Sysoev <igor@sysoev.ru>
parents:
1177
diff
changeset
|
105 |
a77f6980de50
rename $r->rflush to $r->flush
Igor Sysoev <igor@sysoev.ru>
parents:
1177
diff
changeset
|
106 $r->flush; |
a77f6980de50
rename $r->rflush to $r->flush
Igor Sysoev <igor@sysoev.ru>
parents:
1177
diff
changeset
|
107 } |
a77f6980de50
rename $r->rflush to $r->flush
Igor Sysoev <igor@sysoev.ru>
parents:
1177
diff
changeset
|
108 |
a77f6980de50
rename $r->rflush to $r->flush
Igor Sysoev <igor@sysoev.ru>
parents:
1177
diff
changeset
|
109 |
599 | 110 1; |
111 __END__ | |
112 | |
113 =head1 NAME | |
114 | |
115 nginx - Perl interface to the nginx HTTP server API | |
116 | |
117 =head1 SYNOPSIS | |
118 | |
119 use nginx; | |
120 | |
121 =head1 DESCRIPTION | |
122 | |
123 This module provides a Perl interface to the nginx HTTP server API. | |
124 | |
125 | |
126 =head1 SEE ALSO | |
127 | |
4977
b216d212920b
Brought the link to ngx_http_perl_module documentation up to date.
Ruslan Ermilov <ru@nginx.com>
parents:
4942
diff
changeset
|
128 http://nginx.org/en/docs/http/ngx_http_perl_module.html |
599 | 129 |
130 =head1 AUTHOR | |
131 | |
132 Igor Sysoev | |
133 | |
134 =head1 COPYRIGHT AND LICENSE | |
135 | |
136 Copyright (C) Igor Sysoev | |
4411 | 137 Copyright (C) Nginx, Inc. |
599 | 138 |
139 | |
140 =cut |