Permalink
Browse files

add a test for external interpretation of php scripts

  • Loading branch information...
capflam authored and vinoski committed May 27, 2011
1 parent 52e8852 commit 61181690949241fdbdfd7f951389bfbdf0130a8e
Showing with 35 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +1 −0 test/conf/stdconf.conf
  3. +4 −1 test/t2/Makefile
  4. +9 −0 test/t2/app_test.erl
  5. +20 −0 test/t2/phptest.erl
View
@@ -31,6 +31,7 @@ test/t[12]/yaws.conf
www/yaws.pdf
www/yaws.ps
www/*.txt
+www/test.php
applications/yapp/doc/edoc-info
applications/yapp/doc/erlang.png
applications/yapp/doc/index.html
View
@@ -160,6 +160,7 @@ use_fdsrv = false
listen = 0.0.0.0
docroot = %YTOP%/www
auth_log = true
+ php_handler = <extern, phptest:out>
expires = <image/gif, access+2592000>
appmods = posttest reentranttest
</server>
View
@@ -4,7 +4,7 @@ include ../support/include.mk
#
all: conf setup app_test.beam streamtest.beam jsontest.beam posttest.beam \
- reentranttest.beam
+ reentranttest.beam phptest.beam
@echo "all ok"
@@ -19,6 +19,7 @@ test: conf start
dd if=/dev/zero of=../../www/2000.txt bs=1024 count=2000 >/dev/null 2>&1
dd if=/dev/zero of=../../www/3000.txt bs=1024 count=3000 >/dev/null 2>&1
dd if=/dev/zero of=../../www/10000.txt bs=1024 count=10000 >/dev/null 2>&1
+ echo '<? echo "Hello, world!"; ?>' > ../../www/test.php
ul=`ulimit -n` ; \
val=`expr $$ul '<' $(ULIMIT)` ; \
if [ $$val = 1 ] ; then \
@@ -35,4 +36,6 @@ debug:
$(ERL) $(PA)
clean: tclean
+ -rm -f ../../www/1000.txt ../../www/2000.txt ../../www/3000.txt ../../www/10000.txt
+ -rm -f ../../www/test.php
-rm -rf localhost:8000 logs yaws.conf
View
@@ -24,6 +24,7 @@ start() ->
post_test(),
expires_test(),
reentrant_test(),
+ php_handler_test(),
ibrowse:stop().
@@ -609,6 +610,14 @@ reentrant_test_delayed_headers() ->
+php_handler_test() ->
+ io:format("php_handler_test\n", []),
+ Uri = "http://localhost:8006/test.php",
+ {ok, Binary} = file:read_file("../../www/test.php"),
+ Content = binary_to_list(Binary),
+ ?line {ok, "200", _, Content} = ibrowse:send_req(Uri, [], get),
+ ok.
+
%% used for appmod tests
%%
out(_A) ->
View
@@ -0,0 +1,20 @@
+-module(phptest).
+-export([out/1]).
+
+-include("../../include/yaws.hrl").
+-include("../../include/yaws_api.hrl").
+
+out(Arg) ->
+ File = Arg#arg.fullpath,
+ case filelib:is_file(File) of
+ true ->
+ case file:read_file(File) of
+ {ok, Content} ->
+ [{status, 200}, {content, "text/plain", Content}];
+ {error, Reason} ->
+ [{status, 500}, {html, file:format_error(Reason)}]
+ end;
+ false ->
+ Reason = "file not found: " ++ File,
+ [{status, 500}, {html, Reason}]
+ end.

0 comments on commit 6118169

Please sign in to comment.