/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

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