location ~ ^/post(.*)$ {
content_by_lua_file ${APIDIR}/post-api.lua;
}
+
+ location ~ ^/delay(.*)$ {
+ content_by_lua_file ${APIDIR}/delay-api.lua;
+ }
}
server {
--- /dev/null
+-- Simple API represending a slow response for testing timeouts
+
+local t0 = os.clock()
+while os.clock() - t0 <= 2 do end
+
+ngx.say("Delayed response")
xlat {
tls = ${..tls}
+ timeout = 0.5
}
authorize {
test_fail
}
+# Test against endpoint which will time out
+&Tmp-String-2 := "%(rest:http://%{Tmp-String-0}:%{Tmp-Integer-0}/delay)"
+
+if (&REST-HTTP-Status-Code) {
+ test_fail
+}
+
+if (!(&Module-Failure-Message == "curl request failed: Timeout was reached (28)")) {
+ test_fail
+}
+
test_pass