Skip to content

Commit

Permalink
add tests for reentrant requests (scripts returning {page, P})
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Faulet authored and vinoski committed May 28, 2011
1 parent aab5243 commit 52e8852
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/conf/stdconf.conf
Expand Up @@ -161,6 +161,6 @@ use_fdsrv = false
docroot = %YTOP%/www
auth_log = true
expires = <image/gif, access+2592000>
appmods = posttest
appmods = posttest reentranttest
</server>

3 changes: 2 additions & 1 deletion test/t2/Makefile
Expand Up @@ -3,7 +3,8 @@ include ../support/include.mk
.PHONY: all test debug clean

#
all: conf setup app_test.beam streamtest.beam jsontest.beam posttest.beam
all: conf setup app_test.beam streamtest.beam jsontest.beam posttest.beam \
reentranttest.beam
@echo "all ok"


Expand Down
25 changes: 25 additions & 0 deletions test/t2/app_test.erl
Expand Up @@ -23,6 +23,7 @@ start() ->
json_test(),
post_test(),
expires_test(),
reentrant_test(),
ibrowse:stop().


Expand Down Expand Up @@ -584,6 +585,30 @@ expires_test() ->
?line Val1 = Val2,
ok.


reentrant_test() ->
io:format("reentrant_test\n", []),
reentrant_test_status(),
reentrant_test_delayed_headers(),
ok.

reentrant_test_status() ->
io:format(" status code\n", []),
Uri = "http://localhost:8006/reentranttest/status",
?line {ok, "201", _, _} = ibrowse:send_req(Uri, [], post, <<"blob">>, []),
ok.

reentrant_test_delayed_headers() ->
io:format(" delayed headers\n", []),
Uri = "http://localhost:8006/reentranttest/delayed_headers",
?line {ok, "200", Hdrs, _} = ibrowse:send_req(Uri, [], get),
?line "no-cache" = proplists:get_value("Cache-Control", Hdrs),
?line "static-tag" = proplists:get_value("Etag", Hdrs),
?line "true" = proplists:get_value("X-Delayed-Header", Hdrs),
ok.



%% used for appmod tests
%%
out(_A) ->
Expand Down
21 changes: 21 additions & 0 deletions test/t2/reentranttest.erl
@@ -0,0 +1,21 @@
-module(reentranttest).
-export([out/1]).

-include("../../include/yaws.hrl").
-include("../../include/yaws_api.hrl").

out(Arg) ->
Url = yaws_api:request_url(Arg),
case Url#url.path of
"/reentranttest/status" ->
{page, {[{status, 201}], "/icons/yaws.gif"}};
"/reentranttest/delayed_headers" ->
Hdrs = [{header, {cache_control, "no-cache"}},
{header, "Etag: static-tag"},
{header, "X-Delayed-Header: true"}],
{page, {Hdrs, "/icons/yaws.gif"}};
_ ->
Reason = "unknown path: " ++ Url#url.path,
[{status, 500}, {html, Reason}]
end.

0 comments on commit 52e8852

Please sign in to comment.