179
=== TEST 8: github issue 37: header bug
180
https://github.com/chaoslawful/lua-nginx-module/issues/37
184
ngx.header["Set-Cookie"] = {"TestCookie1=foo", "TestCookie2=bar"};
190
-- local yajl = require "yajl"
191
ngx.header["Set-Cookie"] = {}
192
res = ngx.location.capture("/sub")
194
for i,j in pairs(res.header) do
198
-- ngx.say("set-cookie: ", yajl.to_string(res.header["Set-Cookie"]))
201
ngx.print("body: ", res.body)
206
--- raw_response_headers_like eval
207
".*Set-Cookie: TestCookie1=foo\r
208
Set-Cookie: TestCookie2=bar.*"
212
=== TEST 9: memory leak
215
content_by_lua_file 'html/foo.lua';
220
res = {'good 1', 'good 2', 'good 3'}
221
return ngx.redirect("/somedir/" .. ngx.escape_uri(res[math.random(1,#res)]))
229
=== TEST 10: capturing locations with internal redirects (no lua redirect)
242
local res = ngx.location.capture("/foo")
253
=== TEST 11: capturing locations with internal redirects (lua redirect)
256
content_by_lua 'ngx.say("Bar")';
265
local res = ngx.location.capture("/foo")
276
=== TEST 12: capturing locations with internal redirects (simple index)
280
local res = ngx.location.capture("/")
286
--- response_body chop
287
<html><head><title>It works!</title></head><body>It works!</body></html>
291
=== TEST 13: capturing locations with internal redirects (more lua statements)
307
local res = ngx.location.capture("/foo")
319
=== TEST 14: capturing locations with internal redirects (post subrequest with internal redirect)
322
lua_need_request_body on;
323
client_body_in_single_buffer on;
326
ngx.say(ngx.var.request_body)
337
local res = ngx.location.capture("/foo", { method = ngx.HTTP_POST, body = "hello" })
348
=== TEST 15: nginx rewrite works in subrequests
350
rewrite /foo /foo/ permanent;
356
local res = ngx.location.capture("/foo")
357
ngx.say("status = ", res.status)
358
ngx.say("Location: ", res.header["Location"] or "nil")
369
=== TEST 16: nginx rewrite works in subrequests
372
local res = ngx.location.capture(ngx.var.uri)
373
ngx.say("status = ", res.status)
374
ngx.say("Location: ", res.header["Location"] or "nil")
388
=== TEST 17: set content-type header with charset
393
ngx.header.content_type = "text/xml; charset=UTF-8"
402
Content-Type: text/xml; charset=UTF-8
406
=== TEST 18: set response header content-type with charset
411
ngx.header.content_type = "text/xml"
420
Content-Type: text/xml; charset=GBK
424
=== TEST 19: get by-position capturing variables
426
location ~ '^/lua/(.*)' {
428
ngx.say(ngx.var[1] or "nil")
438
=== TEST 20: get by-position capturing variables ($0)
440
location ~ '^/lua/(.*)' {
442
ngx.say(ngx.var[0] or "nil")
452
=== TEST 21: get by-position capturing variables (exceeding captures)
454
location ~ '^/lua/(.*)' {
456
ngx.say(ngx.var[2] or "nil")
466
=== TEST 22: get by-position capturing variables ($1, $2)
468
location ~ '^/lua/(.*)/(.*)' {
470
ngx.say(ngx.var[-1] or "nil")
471
ngx.say(ngx.var[0] or "nil")
472
ngx.say(ngx.var[1] or "nil")
473
ngx.say(ngx.var[2] or "nil")
474
ngx.say(ngx.var[3] or "nil")
475
ngx.say(ngx.var[4] or "nil")