Class: NanoServe::HTTPResponder::Response

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

Instance Method Summary collapse

Instance Method Details

#bodyObject



224
225
226
# File 'lib/nanoserve.rb', line 224

def body
  @body ||= ''
end

#body=(value) ⇒ Object



228
229
230
# File 'lib/nanoserve.rb', line 228

def body=(value)
  @body = value.tap { @content_length = value.bytes.count.to_s }
end

#headersObject



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/nanoserve.rb', line 212

def headers
  {
    'Date'             => date,
    'Content-Type'     => content_type,
    'Content-Length'   => content_length,
    'Last-Modified'    => last_modified,
    'Server'           => server,
    'ETag'             => etag,
    'Connection'       => connection,
  }
end

#to_sObject



232
233
234
# File 'lib/nanoserve.rb', line 232

def to_s
  (status_line + header_block + body_block).encode('ASCII-8BIT')
end