File: test.cgi

package info (click to toggle)
libnora-ruby 1%3A0.0.20041021-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 408 kB
  • ctags: 722
  • sloc: ruby: 5,186; ansic: 669; makefile: 266; sql: 10
file content (64 lines) | stat: -rwxr-xr-x 1,852 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/local/bin/ruby -Ks
#require 'reqnora'
require 'web/common'
require 'web/interface'
require 'web/cookie'
require 'web/response'

def noratest(req,rsp)
  rsp.content_type = 'text/html; charset=Shift_JIS'
  
  rsp.write <<-EOS
  <html>
  <head>
  <title>Nora Test</title>
  </head>
  <body>
  <h1>Nora Test</h1>
  EOS

  # attr
  rsp << "<table border>"
  rsp << "<tr><td>method</td><td>#{Web::escapeHTML(req.method)}</td></tr>"
  rsp << "<tr><td>query_string</td><td>#{Web::escapeHTML(req.query_string)}</td></tr>"
  rsp << "<tr><td>script_name</td><td>#{Web::escapeHTML(req.script_name)}</td></tr>"
  rsp << "<tr><td>path_info</td><td>#{Web::escapeHTML(req.path_info)}</td></tr>"
  rsp << "<tr><td>host</td><td>#{Web::escapeHTML(req.host.to_s)}</td></tr>"
  rsp << "<tr><td>remote_addr</td><td>#{Web::escapeHTML(req.remote_addr.to_s)}</td></tr>"
  rsp << "<tr><td>remote_host</td><td>#{Web::escapeHTML(req.remote_host.to_s)}</td></tr>"
  rsp << "<tr><td>remote_ident</td><td>#{Web::escapeHTML(req.remote_ident || '')}</td></tr>"
  rsp << "<tr><td>remote_user</td><td>#{Web::escapeHTML(req.remote_user || '')}</td></tr>"
  rsp << "</table>"
  
  # query
  rsp << "<h2>query</h2>"
  rsp << "<table border>"
  req.query.each {|key,value|
    rsp << "<tr><td>#{Web::escapeHTML(key)}</td><td>#{Web::escapeHTML(value.inspect)}</td></tr>"
  }
  rsp << "</table>"
  
  # form
  rsp << "<h2>form</h2>"
  rsp << "<table border>"
  req.form.each {|key,value|
    rsp << "<tr><td>#{Web::escapeHTML(key)}</td><td>#{Web::escapeHTML(value.inspect)}</td></tr>"
  }
  rsp << "</table>"
  
  rsp << "<h2>Web::Request</h2>"
  rsp << "<p>" << Web::escapeHTML(req.inspect) << "</p>"
  
  rsp.write <<-EOS
  </body>
  </html>
  EOS
  rsp
end

api = Web::Interface::AUTO.new
api.each {|req|
  rsp = Web::Response.new
  rsp = noratest(req,rsp)
  api.response req, rsp
}