Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: added new API function ngx.req.is_internal() for testing if …
…the current request is an internal request. thanks Ruoshan Huang for the patch in #350.
- Loading branch information
Showing
6 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use Test::Nginx::Socket::Lua; | ||
|
||
#master_on(); | ||
#workers(1); | ||
#worker_connections(1014); | ||
#log_level('warn'); | ||
#master_process_enabled(1); | ||
|
||
repeat_each(2); | ||
|
||
plan tests => repeat_each() * blocks() * 2; | ||
|
||
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211; | ||
|
||
#no_diff(); | ||
no_long_string(); | ||
#no_shuffle(); | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
|
||
=== TEST 1: not internal request | ||
--- config | ||
location /test { | ||
rewrite ^/test$ /lua last; | ||
} | ||
location /lua { | ||
content_by_lua ' | ||
if ngx.req.is_internal() then | ||
ngx.say("internal") | ||
else | ||
ngx.say("not internal") | ||
end | ||
'; | ||
} | ||
--- request | ||
GET /lua | ||
--- response_body | ||
not internal | ||
|
||
|
||
|
||
=== TEST 2: internal request | ||
--- config | ||
location /test { | ||
rewrite ^/test$ /lua last; | ||
} | ||
location /lua { | ||
content_by_lua ' | ||
if ngx.req.is_internal() then | ||
ngx.say("internal") | ||
else | ||
ngx.say("not internal") | ||
end | ||
'; | ||
} | ||
--- request | ||
GET /test | ||
--- response_body | ||
internal | ||
|