Class: NaiveHttpResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/bane/naive_http_response.rb

Defined Under Namespace

Classes: HttpHeader

Constant Summary collapse

CRLF =
"\r\n"

Instance Method Summary collapse

Constructor Details

#initialize(response_code, response_description, content_type, body) ⇒ NaiveHttpResponse

Returns a new instance of NaiveHttpResponse.



18
19
20
21
22
23
# 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

Instance Method Details

#to_sObject



25
26
27
28
29
30
31
32
# 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