Parent

Namespace

Kcar::Response

This may be used to generate a Rack response

Constants

READ_SIZE

By default we readpartial at most 16K off a socket at once

Attributes

buf[RW]
hdr[RW]
parser[RW]
sock[RW]
unchunk[RW]

Public Class Methods

new(sock, hdr = {}, unchunk = true) view method source

initializes a socket, sock must respond to the “readpartial” method. unchunk may be set to disable transparent unchunking hdr may be a Hash, Array, or Rack::Utils::HeaderHash

Public Instance Methods

this is expected to be called by our Rack server, it will close our given sock object if keepalive is not used otherwise it will just reset the parser and clear the header object

this method allows our Kcar::Response object to be used as a Rack response body. It may only be called once (usually by a Rack server) as it streams the response body off the our socket object.

returns a 3-element array suitable for use as a Rack response:

[ status, headers, body ]

this method will not return until the response headers are fully parsed, but the body returned will be this Kcar::Response handler itself. It is not guaranteed that trailers will be stored in the returned header

returns a 3-element array that resembles a Rack response, but is more useful for additional processing by other code.

[ status, headers, body ]

Use Kcar::Response#rack if you want to guaranteee a proper Rack response.

this method will not return until the response headers are fully parsed, but the body returned will be this Kcar::Response handler itself. unchunk must be true to guarantee trailers will be stored in the returned header object

Originally generated with the Darkfish Rdoc Generator 2, modified by wrongdoc.