Sha256: 39d64014ecded03df8bedbcee8b109cec2f13a693ecae5322b86f65d40171637
Contents?: true
Size: 986 Bytes
Versions: 1
Compression:
Stored size: 986 Bytes
Contents
module Thin # A response sent to the client. class Response CONTENT_LENGTH = 'Content-Length'.freeze CONNECTION = 'Connection'.freeze CLOSE = 'close'.freeze attr_accessor :status attr_reader :headers, :body def initialize @headers = Headers.new @body = StringIO.new @status = 200 end def headers_output @headers[CONTENT_LENGTH] = @body.size @headers[CONNECTION] = CLOSE @headers.to_s end def head "HTTP/1.1 #{@status} #{HTTP_STATUS_CODES[@status.to_i]}\r\n#{headers_output}\r\n" end def headers=(key_value_pairs) key_value_pairs.each do |k, vs| vs.each do |v| @headers[k] = v end end end def body=(stream) stream.each do |part| @body << part end end def close @body.close end def to_s @body.rewind head + @body.read end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thin-0.5.0 | lib/thin/response.rb |