Class: Spider::HTTP::WEBrick
- Inherits:
-
Server
show all
- Defined in:
- lib/spiderfw/http/adapters/webrick.rb
Instance Method Summary
collapse
Methods inherited from Server
get_opts, #request_received, #shutdown, #start, start, supports?
Instance Method Details
#options(opts) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/spiderfw/http/adapters/webrick.rb', line 13
def options(opts)
opts = super(opts)
defaults = {
:host => 'localhost',
:app => 'spider'
}
return defaults.merge(opts)
end
|
#shutdown_server ⇒ Object
44
45
46
|
# File 'lib/spiderfw/http/adapters/webrick.rb', line 44
def shutdown_server
@server.shutdown
end
|
#start_server(opts = {}) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/spiderfw/http/adapters/webrick.rb', line 23
def start_server(opts={})
opts = options(opts)
options = {
:Port => opts[:port],
:BindAddress => opts[:host]
}
if (opts[:ssl])
require 'webrick/https'
require 'openssl'
options[:SSLEnable] = true
options[:SSLVerifyClient] = ::OpenSSL::SSL::VERIFY_NONE
options[:SSLCertificate] = OpenSSL::X509::Certificate.new(File.open(opts[:ssl_cert]).read)
options[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(File.open(opts[:ssl_private_key]).read)
end
options[:Logger] = Spider.logger
@server = ::WEBrick::HTTPServer.new(options)
@server.mount("/", WEBrickServlet)
@server.start
end
|