Module: Httpserver::Response
- Included in:
- WebServer
- Defined in:
- lib/httpserver/response.rb
Instance Method Summary collapse
Instance Method Details
#response(attrs) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/httpserver/response.rb', line 3 def response(attrs) code = attrs[:code].to_i mime = attrs[:mime] || "text/html" content = attrs[:content] || "" status = "" case(code) when 200 status = "OK" when 404 status = "Object Not Found" return "HTTP/1.1 #{code}/#{status}\r\nServer HttpServer\r\n\r\n#{content}" end "HTTP/1.1 #{code}/#{status}\r\nContent-type:#{mime}\r\n\r\n#{content}" end |