summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-11-02 19:58:57 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-12-10 18:06:25 +0900
commit05cc58c2ebc467ebc18897b1aef2c2089b26adf3 (patch)
treec0d751edd9af9b1a5079c70b5d744bc95be37f39 /sample
parent0e73b49b4c35a3ae8fd5530a730556b4e4ef4377 (diff)
webrick was removed from ruby repo
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3729
Diffstat (limited to 'sample')
-rw-r--r--sample/webrick/demo-app.rb66
-rw-r--r--sample/webrick/demo-multipart.cgi12
-rw-r--r--sample/webrick/demo-servlet.rb6
-rw-r--r--sample/webrick/demo-urlencoded.cgi12
-rw-r--r--sample/webrick/hello.cgi11
-rw-r--r--sample/webrick/hello.rb8
-rw-r--r--sample/webrick/httpd.rb23
-rw-r--r--sample/webrick/httpproxy.rb25
-rw-r--r--sample/webrick/httpsd.rb33
9 files changed, 0 insertions, 196 deletions
diff --git a/sample/webrick/demo-app.rb b/sample/webrick/demo-app.rb
deleted file mode 100644
index c7a2a0a6a4..0000000000
--- a/sample/webrick/demo-app.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-require "pp"
-
-module DemoApplication
- def initialize(config, enctype)
- super
- @enctype = enctype
- end
-
- def do_GET(req, res)
- if req.path_info != "/"
- res.set_redirect(WEBrick::HTTPStatus::Found, req.script_name + "/")
- end
- res.body =<<-_end_of_html_
- <HTML>
- <FORM method="POST" enctype=#{@enctype}>
- text: <INPUT type="text" name="text"><BR>
- file: <INPUT type="file" name="file"><BR>
- check:
- <INPUT type="checkbox" name="check" value="a">a,
- <INPUT type="checkbox" name="check" value="b">b,
- <INPUT type="checkbox" name="check" value="c">c,
- <BR>
- <INPUT type="submit">
- </FORM>
- </HTML>
- _end_of_html_
- res['content-type'] = 'text/html; charset=iso-8859-1'
- end
-
- def do_POST(req, res)
- if req["content-length"].to_i > 1024*10
- raise WEBrick::HTTPStatus::Forbidden, "file size too large"
- end
- res.body =<<-_end_of_html_
- <HTML>
- <H2>Query Parameters</H2>
- #{display_query(req.query)}
- <A href="#{req.path}">return</A>
- <H2>Request</H2>
- <PRE>#{WEBrick::HTMLUtils::escape(PP::pp(req, "", 80))}</PRE>
- <H2>Response</H2>
- <PRE>#{WEBrick::HTMLUtils::escape(PP::pp(res, "", 80))}</PRE>
- </HTML>
- _end_of_html_
- res['content-type'] = 'text/html; charset=iso-8859-1'
- end
-
- private
-
- def display_query(q)
- ret = ""
- q.each{|key, val|
- ret << "<H3>#{WEBrick::HTMLUtils::escape(key)}</H3>"
- ret << "<TABLE border=1>"
- ret << make_tr("val", val.inspect)
- ret << make_tr("val.to_a", val.to_a.inspect)
- ret << make_tr("val.to_ary", val.to_ary.inspect)
- ret << "</TABLE>"
- }
- ret
- end
-
- def make_tr(arg0, arg1)
- "<TR><TD>#{arg0}</TD><TD>#{WEBrick::HTMLUtils::escape(arg1)}</TD></TR>"
- end
-end
diff --git a/sample/webrick/demo-multipart.cgi b/sample/webrick/demo-multipart.cgi
deleted file mode 100644
index 0893fadadf..0000000000
--- a/sample/webrick/demo-multipart.cgi
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env ruby
-require "webrick/cgi"
-require "webrick/https" # should load if it runs on HTTPS server
-require "./demo-app"
-
-class DemoCGI < WEBrick::CGI
- include DemoApplication
-end
-
-config = { :NPH => false }
-cgi = DemoCGI.new(config, "multipart/form-data")
-cgi.start
diff --git a/sample/webrick/demo-servlet.rb b/sample/webrick/demo-servlet.rb
deleted file mode 100644
index 9c18cc65d1..0000000000
--- a/sample/webrick/demo-servlet.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require "webrick"
-require "./demo-app"
-
-class DemoServlet < WEBrick::HTTPServlet::AbstractServlet
- include DemoApplication
-end
diff --git a/sample/webrick/demo-urlencoded.cgi b/sample/webrick/demo-urlencoded.cgi
deleted file mode 100644
index e4706f8b59..0000000000
--- a/sample/webrick/demo-urlencoded.cgi
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env ruby
-require "webrick/cgi"
-require "webrick/https" # should load if it runs on HTTPS server
-require "./demo-app"
-
-class DemoCGI < WEBrick::CGI
- include DemoApplication
-end
-
-config = { :NPH => false }
-cgi = DemoCGI.new(config, "application/x-www-form-urlencoded")
-cgi.start
diff --git a/sample/webrick/hello.cgi b/sample/webrick/hello.cgi
deleted file mode 100644
index 35d2240df0..0000000000
--- a/sample/webrick/hello.cgi
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env ruby
-require "webrick/cgi"
-
-class HelloCGI < WEBrick::CGI
- def do_GET(req, res)
- res["content-type"] = "text/plain"
- res.body = "Hello, world.\n"
- end
-end
-
-HelloCGI.new.start
diff --git a/sample/webrick/hello.rb b/sample/webrick/hello.rb
deleted file mode 100644
index 4d02676818..0000000000
--- a/sample/webrick/hello.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require "webrick"
-
-class HelloServlet < WEBrick::HTTPServlet::AbstractServlet
- def do_GET(req, res)
- res["content-type"] = "text/plain"
- res.body = "Hello, world.\n"
- end
-end
diff --git a/sample/webrick/httpd.rb b/sample/webrick/httpd.rb
deleted file mode 100644
index b0edf47582..0000000000
--- a/sample/webrick/httpd.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require "webrick"
-
-httpd = WEBrick::HTTPServer.new(
- :DocumentRoot => File::dirname(__FILE__),
- :Port => 10080,
- :Logger => WEBrick::Log.new($stderr, WEBrick::Log::DEBUG),
- :AccessLog => [
- [ $stderr, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
- [ $stderr, WEBrick::AccessLog::REFERER_LOG_FORMAT ],
- [ $stderr, WEBrick::AccessLog::AGENT_LOG_FORMAT ],
- ],
- :CGIPathEnv => ENV["PATH"] # PATH environment variable for CGI.
-)
-
-require "./hello"
-httpd.mount("/hello", HelloServlet)
-
-require "./demo-servlet"
-httpd.mount("/urlencoded", DemoServlet, "application/x-www-form-urlencoded")
-httpd.mount("/multipart", DemoServlet, "multipart/form-data")
-
-trap(:INT){ httpd.shutdown }
-httpd.start
diff --git a/sample/webrick/httpproxy.rb b/sample/webrick/httpproxy.rb
deleted file mode 100644
index c84457ece7..0000000000
--- a/sample/webrick/httpproxy.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require "webrick"
-require "webrick/httpproxy"
-
-# The :ProxyContentHandler proc will be invoked before sending a response to
-# the User-Agent. You can inspect the pair of request and response messages
-# (or edit the response message if necessary).
-
-pch = Proc.new{|req, res|
- p [ req.request_line, res.status_line ]
-}
-
-def upstream_proxy
- if prx = ENV["http_proxy"]
- return URI.parse(prx)
- end
- return nil
-end
-
-httpd = WEBrick::HTTPProxyServer.new(
- :Port => 10080,
- :ProxyContentHandler => pch,
- :ProxyURI => upstream_proxy
-)
-Signal.trap(:INT){ httpd.shutdown }
-httpd.start
diff --git a/sample/webrick/httpsd.rb b/sample/webrick/httpsd.rb
deleted file mode 100644
index a120782c3c..0000000000
--- a/sample/webrick/httpsd.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require "webrick"
-require "webrick/https"
-
-hostname = WEBrick::Utils::getservername
-subject = [["O", "ruby-lang.org"], ["OU", "sample"], ["CN", hostname]]
-comment = "Comment for self-signed certificate"
-
-httpd = WEBrick::HTTPServer.new(
- :DocumentRoot => File::dirname(__FILE__),
- :Port => 10443,
- :SSLEnable => true,
-
- # Specify key pair and server certificate.
- # :SSLPrivateKey => OpenSSL::PKey::RSA.new(File.read("server.key")),
- # :SSLCertificate => OpenSSL::X509::Certificate.new(File.read("server.crt")),
-
- # specify the following SSL options if you want to use auto
- # generated self-signed certificate.
- :SSLCertName => subject,
- :SSLComment => comment,
-
- :CGIPathEnv => ENV["PATH"] # PATH environment variable for CGI.
-)
-
-require "./hello"
-httpd.mount("/hello", HelloServlet)
-
-require "./demo-servlet"
-httpd.mount("/urlencoded", DemoServlet, "application/x-www-form-urlencoded")
-httpd.mount("/multipart", DemoServlet, "multipart/form-data")
-
-trap(:INT){ httpd.shutdown }
-httpd.start