Module: TestServerModule

Defined in:
lib/wdd-ruby-ext/utils/test_server.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



61
62
63
# File 'lib/wdd-ruby-ext/utils/test_server.rb', line 61

def self.included(base)
  base.send(:include, HTTPHandler) unless base.include?( HTTPHandler )
end

Instance Method Details

#loggerObject



83
84
85
# File 'lib/wdd-ruby-ext/utils/test_server.rb', line 83

def logger
  TestServer.logger
end

#post_initObject



65
66
67
# File 'lib/wdd-ruby-ext/utils/test_server.rb', line 65

def post_init
  logger.debug 'got connection'
end

#receive_data(data) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/wdd-ruby-ext/utils/test_server.rb', line 69

def receive_data(data)
  Thread.new do
    logger.debug "Got data:\n#{data}"
    if http_request = http_request?( data )
      return_data = process_http_request( http_request )
    else
      return_data = "Your request was processed by the TestServer."
    end
    send_data(return_data)
    logger.debug "Sent: #{return_data}"
    close_connection_after_writing
  end
end