Class: HTTPkit::Serializer

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

Overview

Streaming HTTP message serializer.

Constant Summary

REQUEST_LINE =
"%s %s HTTP/%.1f\r\n".freeze
RESPONSE_LINE =
"HTTP/%.1f %d %s\r\n".freeze
HEADER =
"%s: %s\r\n".freeze
TRANSFER_ENCODING =
'Transfer-Encoding'.freeze
CHUNKED =
'chunked'.freeze
CONTENT_LENGTH =
'Content-Length'.freeze
CRLF =
"\r\n".freeze

Instance Method Summary collapse

Constructor Details

#initialize(message, writer) ⇒ Serializer

Returns a new instance of Serializer



17
18
19
# File 'lib/httpkit/serializer.rb', line 17

def initialize(message, writer)
  @message, @writer = message, writer
end

Instance Method Details

#serializeObject



21
22
23
24
25
# File 'lib/httpkit/serializer.rb', line 21

def serialize
  write(first_line)
  write(header_block)
  write_body
end