class NaiveHttpResponse
Constants
- CRLF
Public Class Methods
new(response_code, response_description, content_type, body)
click to toggle source
# File lib/bane/naive_http_response.rb, line 18 def initialize(response_code, response_description, content_type, body) @code = response_code @description = response_description @content_type = content_type @body = body end
Public Instance Methods
to_s()
click to toggle source
# File lib/bane/naive_http_response.rb, line 25 def to_s str = [] str << "HTTP/1.1 #{@code} #{@description}" str << http_header.to_s str << "" str << @body str.join(CRLF) end
Private Instance Methods
http_date(time)
click to toggle source
# File lib/bane/naive_http_response.rb, line 45 def http_date(time) time.gmtime.strftime("%a, %d %b %Y %H:%M:%S GMT") end
http_header()
click to toggle source
# File lib/bane/naive_http_response.rb, line 36 def http_header() HttpHeader.new( {"Server" => "Bane HTTP Server", "Connection" => "close", "Date" => http_date(Time.now), "Content-Type" => @content_type, "Content-Length" => @body.length}) end