Class: FakeSMTPd::HTTPServer
- Inherits:
-
GServer
- Object
- GServer
- FakeSMTPd::HTTPServer
- Defined in:
- lib/fakesmtpd/server.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#smtpd ⇒ Object
readonly
Returns the value of attribute smtpd.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ HTTPServer
constructor
A new instance of HTTPServer.
- #serve(io) ⇒ Object
- #start(*args) ⇒ Object
- #stop(*args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ HTTPServer
Returns a new instance of HTTPServer.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fakesmtpd/server.rb', line 40 def initialize( = {}) @port = .fetch(:port) @smtpd = .fetch(:smtpd) super( @port, [:host] || '0.0.0.0', [:max_connections] || 4, [:logfile], [:audit] || !!ENV['FAKESMTPD_AUDIT'] || false, [:debug] || !!ENV['FAKESMTPD_DEBUG'] || false ) end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
38 39 40 |
# File 'lib/fakesmtpd/server.rb', line 38 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
38 39 40 |
# File 'lib/fakesmtpd/server.rb', line 38 def server @server end |
#smtpd ⇒ Object (readonly)
Returns the value of attribute smtpd.
38 39 40 |
# File 'lib/fakesmtpd/server.rb', line 38 def smtpd @smtpd end |
Instance Method Details
#serve(io) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/fakesmtpd/server.rb', line 64 def serve(io) io.set_encoding('UTF-8') request_line = io.gets path = request_line.split[1] handle_client(request_line, path, io) rescue => e handle_500(path, io, e) end |
#start(*args) ⇒ Object
53 54 55 56 57 |
# File 'lib/fakesmtpd/server.rb', line 53 def start(*args) super(*args) log "FakeSMTPd HTTP server serving on #{port}" log "PID=#{$$} Thread=#{Thread.current.inspect}" end |
#stop(*args) ⇒ Object
59 60 61 62 |
# File 'lib/fakesmtpd/server.rb', line 59 def stop(*args) log "FakeSMTPd HTTP server stopping" super(*args) end |