PageRenderTime 61ms CodeModel.GetById 30ms app.highlight 1ms RepoModel.GetById 19ms app.codeStats 0ms

/library/server/fcgi/tests/application_root.e

http://github.com/jocelyn/EiffelWebReloaded
Specman e | 80 lines | 64 code | 15 blank | 1 comment | 0 complexity | dcc2b6e0dc4133c4bdb0860b9ec90180 MD5 | raw file
 1note
 2	description : "Objects that ..."
 3	author      : "$Author$"
 4	date        : "$Date$"
 5	revision    : "$Revision$"
 6
 7class
 8	APPLICATION_ROOT
 9
10create
11	make
12
13feature {NONE} -- Initialization
14
15	make
16			-- Initialize `Current'.
17		local
18			res: INTEGER
19			nb: INTEGER
20		do
21			initialize
22			from
23				res := fcgi.fcgi_listen
24			until
25				res < 0
26			loop
27				nb := nb + 1
28				fcgi.put_string (header ("FCGI Eiffel Application"))
29
30				fcgi.put_string ("<h1>Hello FCGI Eiffel Application</h1>%N")
31				fcgi.put_string ("Request number " + nb.out + "<br/>%N")
32
33				fcgi.put_string ("<ul>Environment variables%N")
34				print_environment_variables (fcgi.updated_environ_variables)
35				fcgi.put_string ("</ul>")
36				fcgi.put_string (footer)
37
38				res := fcgi.fcgi_listen
39			end
40		end
41
42feature -- Access
43
44	header (a_title: STRING): STRING
45		do
46			Result := "Content-type: text/html%R%N"
47			Result.append ("%R%N")
48			Result.append ("<html>%N")
49			Result.append ("<head><title>" + a_title + "</title></head>")
50			Result.append ("<body>%N")
51		end
52
53	footer: STRING
54		do
55			Result := "</body>%N</html>%N"
56		end
57
58	print_environment_variables (vars: HASH_TABLE [STRING, STRING])
59		local
60		do
61			from
62				vars.start
63			until
64				vars.after
65			loop
66				fcgi.put_string ("<li><strong>" + vars.key_for_iteration + "</strong> = " + vars.item_for_iteration + "</li>%N")
67				vars.forth
68			end
69		end
70
71feature {NONE} -- Implementation
72
73	initialize
74		do
75			create fcgi.make
76		end
77
78	fcgi: FCGI
79
80end