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.



16
17
18
19
20
21
# File 'lib/bane/naive_http_response.rb', line 16

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



23
24
25
26
27
28
29
30
# File 'lib/bane/naive_http_response.rb', line 23

def to_s
  str = []
  str << "HTTP/1.1 #{@code} #{@description}"
  str << http_header.to_s
  str << ""
  str << @body
  str.join(CRLF)
end