----Next_Part(Thu_Dec_10_01:20:03_1998_893)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
postgreSQL¤Î¥Ç¡¼¥¿¤òWeb¤Ç¸ø³«¤·¤è¤¦¤È¤¤¤í¤¤¤íºî¤Ã¤Æ¤ë¤¦¤Á¤Ë
¤ª¤â¤·¤í¤¤¤Î¤¬¤Ç¤¤Þ¤·¤¿¡£
¸¶¤µ¤ó¤Î¸ø³«¤µ¤ì¤¿ shttpsrv ¤ò²þ¤¤·¤Æ¡¢ruby¤Î¥â¥¸¥å¡¼¥ë¤ò
¥µ¡¼¥Ð¤ËưŪ¤Ë¥í¡¼¥É¤Ç¤¤ë¤è¤¦¤Ë¤·¤Þ¤·¤¿¡£
ÀßÄê¥Õ¥¡¥¤¥ë¤Ç»ØÄꤷ¤¿URL¤òÍ׵᤹¤ë¤È¡¢html¥Õ¥¡¥¤¥ë¤òžÁ÷¤¹¤ë
Âå¤ï¤ê¤Ë¡¢ruby¤Î¥â¥¸¥å¡¼¥ë¤¬Æ°Åª¤ËÀ¸À®¤·¤¿¥Ú¡¼¥¸¤òžÁ÷¤·¤Þ¤¹¡£
¤Þ¤¿¡¢SSI¤ÎÃæ¤Ç»È¤¦¤³¤È¤â¤Ç¤¤Þ¤¹¡£
ºÇ Υꥯ¥¨¥¹¥È¤Ç¤Ï¡¢¥í¡¼¥É¤¹¤ë»þ´Ö¤¬É¬ÍפǤ¹¤¬¡¨Â
ÆóÅÙÌܰʹߤϡ¢CGI¤è¤ê¤â¤º¤Ã¤È¥ì¥¹¥Ý¥ó¥¹¤¬Áᤤ¤Ç¤¹¡£
¤Þ¤¿¡¢http¤Î¥ê¥¯¥¨¥¹¥È¤ò±Û¤¨¤ÆÄ¹À¸¤¤¹¤ë(?)¥ª¥Ö¥¸¥§¥¯¥È¤ò
»È¤¤¤¿¤¤»þ¤Ë¤âÊØÍø¤Ç¤¹¡£
conf.rb¤Ë
ServletAlias
# [²¾Áۥѥ¹, require¤¹¤ë̾Á°, ¥â¥¸¥å¡¼¥ë̾],
['/rb/', 'testserv.rb', 'TestServ'], #1
['counter', 'counter.rb', 'Counter'] #2
]
¤ÎÍͤ˻ØÄꤷ¤Þ¤¹¡£
#1 ¤Ç¤Ï http://localhost:8088/rb/arg1/arg2/ ¤È¤¤¤¦Í׵᤬¤¢¤ë¤È
require 'testserv.rb'
TestServ.service('arg1/arg2')
¤È¤¤¤¦Ê¸¤¬É¾²Á¤µ¤ì¤Þ¤¹¡£
#2 ¤Ç¤Ï foo.shtml Ãæ¤Ë
<!--#ruby service
ounter args"-->
¤È¤¤¤¦Ê¸¤¬¤¢¤ë¤È
requrie 'counter.rb'
Counter.service_ssi('args', 'foo.shtml')
¤¬É¾²Á¤µ¤ì¤Þ¤¹¡£
service(arg)¤Ç¤Ï¥Ø¥Ã¥À¤ò´Þ¤ó¤À°ì¥Ú¡¼¥¸¤òÀ¸À®¤¹¤ë¤³¤È¤ò´üÂÔ¤·¡¢
service_ssi(arg, filename)¤Ç¤ÏHTML¤Î°ìÉô¤òÀ¸À®¤¹¤ë¤³¤È¤ò´üÂÔ¤·¤Æ¤¤¤Þ¤¹¡£
--
³±
----Next_Part(Thu_Dec_10_01:20:03_1998_893)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=testserv.rb
#!/usr/local/bin/ruby
require 'thread'
module TestServ
@origin ime.now
@count
@mutex utex.new
in
¼¡¤Î¥á¥É¤ÏServletDir ¤Î¼¡¤Î¥¨¥ó¥È¥ê¤ËÂбþ¤¹¤ë¡£
['/rb/testserv/', 'testserv.rb', 'TestServ']
URL "http://localhost:8088/rb/testserv/foo/bar" ¤¬Í׵ᤵ¤ì¤ë¤È¡¢
TestServ.service('foo/bar') ¤È¤¤¤¦¼°¤¬É¾²Á¤µ¤ì¤ë¡£
service¥á¥É¤Ï http °ì¥Ú¡¼¥¸¤òÊÖ¤¹¡£
ßÅ
def service(param)
args aram.split('/')
getpage(args)
end
module_function :service
def service_ssi(param, fname il)
countUp
s ¤³¤Î¥µ¡¼¥Ó¥¹¤Ë#{@count}²óÌܤΥ¢¥¯¥»¥¹¤Ç¤¹¡£°ú¿ô¤Ï#{param}¤Ç¤¹¡£"
if fname
s + --- ¤³¤Î¥Ú¡¼¥¸¤Ï#{File.ctime(fname).to_s}¤Ë¹¹¿·¤µ¤ì¤Þ¤·¤¿"
end
s
end
module_function :service_ssi
def countUp
@mutex.synchronize do
@count +
end
end
module_function :countUp
private :countUp
def getpage(args)
countUp
s <EOF
Content-type: text/html
<HTML>
<HEAD>
<TITLE>testserv.rb</TITLE>
</HEAD>
<BODY>
<H2>testserv.rb</H2>
<P>"#{@origin.to_s}¤«¤é#{@count}²óÌܤΥ¢¥¯¥»¥¹¤Ç¤¹"</P>
<UL>
EOF
args.each do |arg|
s + <LI>#{arg}\n"
end
s + </UL></BODY></HTML>\n"
s
end
module_function :getpage
private :getpage
end
module Counter
@counter }
@m utex.new
def countUp(name)
@m.synchronize do
@counter[name] counter.fetch(name, 1) + 1
end
@counter[name]
end
module_function :countUp
private :countUp
¥»gin
¼¡¤Î¥á¥É¤ÏServletDir ¤Î¼¡¤Î¥¨¥ó¥È¥ê¤ËÂбþ¤¹¤ë¡£
['counter', 'testserv.rb', 'Counter']
foo.shtml¥Õ¥¡¥¤¥ëÃæ¤Î <!--#ruby service
ounter foo"--> ¤È
ÃÖ´¹¤µ¤ì¤ë¡£
Counter.service_ssi('foo', 'htdocs/foo.shtml') ¤È¤¤¤¦¼°¤¬É¾²Á¤µ¤ì¤ë¡£
service_ssi¥á¥É¤Ï http ¤Î°ìÉô¤òÊÖ¤¹
ßÅ
def service_ssi(param, fname il)
param ' unless param
countUp(param).to_s
end
module_function :service_ssi
end
module Modified
def service_ssi(param, fname il)
return '' unless fname
if param.nil? or param ''
t ile.ctime(fname)
else
dir ile.dirname(fname)
t ile.ctime(dir + "/" + param)
end
t.strftime("%y %m %d")
end
module_function :service_ssi
end
if __FILE__ $0
begin
print TestServ.service('arg1/arg2/arg3')
print TestServ.service_ssi('arg1/arg2/arg3')
end
end
----Next_Part(Thu_Dec_10_01:20:03_1998_893)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=ssi-test.shtml
<html>
<head>
<title>
SSI TEST
</title>
</head>
<body>
<h1>SSI TEST</h1>
<!--#exec cmd uby -e 'print Time.now'"--><br>
<!--#exec cmd uby -e 'print Time.now'"--><br>
<!--#ruby service
ounter A"--><br>
<!--#ruby service
ounter A"--><br>
<!--#ruby service
ounter B"--><br>
<!--#ruby service
ounter B"--><br>
<!--#ruby service odified index.html"--><br>
<a href ">home</a>
¡Ä <!--#ruby service odified index.html"-->¹¹¿·
</body>
</html>
----Next_Part(Thu_Dec_10_01:20:03_1998_893)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=servlet.patch
Only in shttpsrv-p: CVS
diff -c shttpsrv-1.0.4/conf.rb shttpsrv-p/conf.rb
*** shttpsrv-1.0.4/conf.rb Tue Sep 29 13:58:28 1998
--- shttpsrv-p/conf.rb Thu Dec 10 01:07:59 1998
***************
*** 28,33 ****
--- 28,45 ----
["/img/", ServerRoot+"/img/"]
]
+ # servlet alias
+ # format : [virtual, require, module]
+ ServletAlias
+ ['/rb/testserv/', 'testserv.rb', 'TestServ'],
+ # requrie 'testserv.rb'
+ # TestServ.service(param)
+ # TestServ.service_ssi(param, file)
+ ['counter', 'testserv.rb', 'Counter'], # SSI
+ ['modified', 'testserv.rb', 'Modified'], # SSI
+ ['/tinyyahoo/', 'tinyyahoo.rb', 'TinyYahoo']
+ ]
+
# directory aliases for executable scripts
ScriptAlias
["/cgi-bin/", ServerRoot+"/cgi-bin/"],
***************
*** 88,94 ****
#LogFile shttpsrv.log"
# set it FALSE, if the machine stands alone (recieve no DNS service)
! #Offline RUE
# HTTP PROXY
# To activate proxy function
--- 100,106 ----
#LogFile shttpsrv.log"
# set it FALSE, if the machine stands alone (recieve no DNS service)
! Offline RUE
# HTTP PROXY
# To activate proxy function
Common subdirectories: shttpsrv-1.0.4/omake and shttpsrv-p/omake
Common subdirectories: shttpsrv-1.0.4/sample and shttpsrv-p/sample
diff -c shttpsrv-1.0.4/shttpsrv.rb shttpsrv-p/shttpsrv.rb
*** shttpsrv-1.0.4/shttpsrv.rb Tue Sep 29 13:52:25 1998
--- shttpsrv-p/shttpsrv.rb Thu Dec 10 01:08:00 1998
***************
*** 223,228 ****
--- 223,239 ----
nil
end
+ def set_servlet
+ for servlet_dir in ServletAlias
+ if @target /^#{servlet_dir[0]}(.*)/
+ if servlet_dir.size 3
+ return [servlet_dir, $1]
+ end
+ end
+ end
+ nil
+ end
+
def ssi?(fname)
return nil unless defined? SSIhtml
SSIhtml.each do |ext|
***************
*** 601,606 ****
--- 612,678 ----
[heads, body]
end
+ def do_servlet(t)
+ servlet_dir, param
+ req require '#{servlet_dir[1]}'"
+ servlet ervlet_dir[2]
+ script #{servlet}.service(param)"
+ heads, data ], ''
+ begin
+ $m.synchronize do
+ eval(req)
+ end
+ data val(script)
+ cgimsg fc822h.new(data)
+ location gimsg['Location']
+ heads1, body gimsg.header, cgimsg.body
+ if location
+ if location /http:\/\//
+ heads << "HTTP/1.0 302 Found"
+ else
+ throw(:aloc, location)
+ end
+ else
+ heads << "HTTP/1.0 200 Script output follows"
+ end
+ heads << "Content-length: #{body.length}"
+ heads << ("Date: " + strdate())
+ rescue
+ print "Error(Servlet): #$!\n"
+ print $@.join("\n"), "\n" if $debug
+ heads1, body ], "<H1>Server Erorr (^^;</H1>#$!\n"
+ heads << "HTTP/1.0 500 Server Error"
+ end
+ heads << Version
+ heads.concat heads1
+ [heads, body]
+ end
+
+ def do_servlet_ssi(str, fname)
+ if str /^(\S+)\s*(.*)$/
+ serv_name 1
+ param 2
+ p(serv_name)
+ p(param)
+ servlet_dir ervletAlias.assoc(serv_name)
+ return '' unless servlet_dir
+ else
+ return ''
+ end
+ req require '#{servlet_dir[1]}'"
+ servlet ervlet_dir[2]
+ script #{servlet}.service_ssi(param, fname)"
+ begin
+ eval(req)
+ data val(script)
+ rescue
+ print "Error(Servlet): #$!\n"
+ print $@.join("\n"), "\n" if $debug
+ data '
+ end
+ data
+ end
+
def dir_head(dir)
headfile ir.sub(/\/?$/, "/" + HeaderName)
if File.file?(headfile)
***************
*** 700,705 ****
--- 772,780 ----
ensure
f.close
end
+ when "ruby"
+ raise "unknown parameter" unless opt "service"
+ result o_servlet_ssi(script, fname)
when "include"
if opt "file"
begin
***************
*** 887,892 ****
--- 962,969 ----
client.authenticate(auth)
elsif cgi lient.set_cgi
client.do_cgi(cgi)
+ elsif servlet lient.set_servlet
+ client.do_servlet(servlet)
else
client.get_image(target)
end
Only in shttpsrv-p: testserv.rb
----Next_Part(Thu_Dec_10_01:20:03_1998_893)----