1
%% ``The contents of this file are subject to the Erlang Public License,
2
%% Version 1.1, (the "License"); you may not use this file except in
3
%% compliance with the License. You should have received a copy of the
4
%% Erlang Public License along with this software. If not, it can be
5
%% retrieved via the world wide web at http://www.erlang.org/.
7
%% Software distributed under the License is distributed on an "AS IS"
8
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
%% the License for the specific language governing rights and limitations
12
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
%% AB. All Rights Reserved.''
16
%% $Id: httpd_example.erl,v 1.1 2008/12/17 09:53:34 mikpe Exp $
18
-module(httpd_example).
20
-export([get/2, post/2, yahoo/2, test1/2]).
22
-export([newformat/3]).
23
%% These are used by the inets test-suite
35
io:format("Env:~p~n",[Env]),
38
"<title>Test1</title>",
41
"<h1>Erlang Body</h1>",
50
"<FORM ACTION=\"/cgi-bin/erl/httpd_example:get\" METHOD=GET>
51
<B>Input:</B> <INPUT TYPE=\"text\" NAME=\"input1\">
52
<INPUT TYPE=\"text\" NAME=\"input2\">
53
<INPUT TYPE=\"submit\"><BR>
63
"<FORM ACTION=\"/cgi-bin/erl/httpd_example:post\" METHOD=POST>
64
<B>Input:</B> <INPUT TYPE=\"text\" NAME=\"input1\">
65
<INPUT TYPE=\"text\" NAME=\"input2\">
66
<INPUT TYPE=\"submit\"><BR>
74
"Location: http://www.yahoo.com\r\n\r\n".
78
top("Default Example"),
79
"<B>Environment:</B> ",io_lib:format("~p",[Env]),"<BR>\n",
80
"<B>Input:</B> ",Input,"<BR>\n",
81
"<B>Parsed Input:</B> ",
82
io_lib:format("~p",[httpd:parse_query(Input)]),"\n",
88
"Content-type: " ++ MimeType ++ "\r\n\r\n".
93
<TITLE>" ++ Title ++ "</TITLE>
102
newformat(SessionID,Env,Input)->
103
mod_esi:deliver(SessionID,"Content-Type:text/html\r\n\r\n"),
104
mod_esi:deliver(SessionID,top("new esi format test")),
105
mod_esi:deliver(SessionID,"This new format is nice<BR>"),
106
mod_esi:deliver(SessionID,"This new format is nice<BR>"),
107
mod_esi:deliver(SessionID,"This new format is nice<BR>"),
108
mod_esi:deliver(SessionID,footer()).
110
%% ------------------------------------------------------
112
delay(Time) when integer(Time) ->
113
i("httpd_example:delay(~p) -> do the delay",[Time]),
115
i("httpd_example:delay(~p) -> done, now reply",[Time]),
116
delay_reply("delay ok");
117
delay(Time) when list(Time) ->
118
delay(httpd_conf:make_integer(Time));
119
delay({ok,Time}) when integer(Time) ->
121
delay({error,_Reason}) ->
122
i("delay -> called with invalid time"),
123
delay_reply("delay failed: invalid delay time").
125
delay_reply(Reply) ->
132
i(F,A) -> io:format(F ++ "~n",A).
134
sleep(T) -> receive after T -> ok end.