diff options
author | makoto kuwata <kwa@kuwata-lab.com> | 2010-06-27 22:05:27 +0900 |
---|---|---|
committer | makoto kuwata <kwa@kuwata-lab.com> | 2010-06-27 22:05:27 +0900 |
commit | 7e21d861dd46cc52a02dbebdb9eb7dfbe31f963a (patch) | |
tree | 2de8c4493f6457a9935a7c5e11a3144d8778454b | |
parent | d83b5c4fd4f66e19978aaa298270e3003bbbbe4f (diff) | |
download | erubis-7e21d861dd46cc52a02dbebdb9eb7dfbe31f963a.tar.gz |
[change] remove cgi module from 'contrib/index.cgi'
-rw-r--r-- | contrib/index.cgi | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/contrib/index.cgi b/contrib/index.cgi index 8d8f7a4..fa2014d 100644 --- a/contrib/index.cgi +++ b/contrib/index.cgi @@ -6,7 +6,6 @@ ### Licsense: same as Erubis ### -require 'cgi' require 'erubis' include Erubis::XmlHelper @@ -24,8 +23,7 @@ end ## main -cgi = CGI.new -content_type = "text/html; charset=#{encoding}" +content_type_header = "Content-Type: text/html; charset=#{encoding}\r\n" begin ## check environment variables @@ -44,18 +42,24 @@ begin eruby = ERUBY.load_file(filepath) # or ERUBY.new(File.read(filepath)) html = eruby.result() ## send response - print cgi.header('Content-Type'=>content_type, 'Content-Length'=>html.length) + print content_type_header + print "Content-Length: #{html.length}\r\n" + print "\r\n" print html rescue HttpError => ex ## handle http error (such as 404 Not Found) - print cgi.header('Content-Type'=>content_type, 'Status'=>ex.status) + print "Status: #{ex.status}\r\n" + print content_type_header + print "\r\n" print "<h2>#{h(ex.status)}</h2>\n" print "<p>#{h(ex.message)}</p>" rescue Exception => ex ## print exception backtrace - print cgi.header('Content-Type'=>content_type, 'Status'=>'500 Internal Error') + print "Status: 500 Internal Server Error\r\n" + print content_type_header + print "\r\n" arr = ex.backtrace print "<pre>\n" print "<b>#{h(arr[0])}: #{h(ex.message)} (#{h(ex.class.name)})</b>\n" |