From b49df828fa9faef2a1f093392625408f3708b1f8 Mon Sep 17 00:00:00 2001 From: makoto kuwata Date: Sun, 27 Jun 2010 22:09:31 +0900 Subject: [change] change 'contrib/index.cgi' to allow to set @encoding --- contrib/index.cgi | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/contrib/index.cgi b/contrib/index.cgi index fa2014d..d740e4e 100644 --- a/contrib/index.cgi +++ b/contrib/index.cgi @@ -10,7 +10,7 @@ require 'erubis' include Erubis::XmlHelper ERUBY = Erubis::Eruby # or Erubis::EscapeEruby -encoding = 'utf-8' +@encoding = nil ## helper class to represent http error class HttpError < Exception @@ -23,7 +23,6 @@ end ## main -content_type_header = "Content-Type: text/html; charset=#{encoding}\r\n" begin ## check environment variables @@ -42,7 +41,9 @@ begin eruby = ERUBY.load_file(filepath) # or ERUBY.new(File.read(filepath)) html = eruby.result() ## send response - print content_type_header + print @encoding \ + ? "Content-Type: text/html; charset=#{@encoding}\r\n" \ + : "Content-Type: text/html\r\n" print "Content-Length: #{html.length}\r\n" print "\r\n" print html @@ -50,7 +51,7 @@ begin rescue HttpError => ex ## handle http error (such as 404 Not Found) print "Status: #{ex.status}\r\n" - print content_type_header + print "Content-Type: text/html\r\n" print "\r\n" print "

#{h(ex.status)}

\n" print "

#{h(ex.message)}

" @@ -58,7 +59,7 @@ rescue HttpError => ex rescue Exception => ex ## print exception backtrace print "Status: 500 Internal Server Error\r\n" - print content_type_header + print "Content-Type: text/html\r\n" print "\r\n" arr = ex.backtrace print "
\n"
-- 
cgit v1.2.1