Class: Gin::Response

Inherits:
Rack::Response
  • Object
show all
Includes:
Constants
Defined in:
lib/gin/response.rb

Constant Summary collapse

NO_HEADER_STATUSES =

:nodoc:

[100, 101, 204, 205, 304].freeze

Constants included from Constants

Constants::ASYNC_CALLBACK, Constants::CACHE_CTRL, Constants::CNT_DISPOSITION, Constants::CNT_LENGTH, Constants::CNT_TYPE, Constants::ENV_DEV, Constants::ENV_PROD, Constants::ENV_STAGE, Constants::ENV_TEST, Constants::EPOCH, Constants::ETAG, Constants::EXPIRES, Constants::FWD_FOR, Constants::FWD_HOST, Constants::GIN_APP, Constants::GIN_CTRL, Constants::GIN_ERRORS, Constants::GIN_PATH_PARAMS, Constants::GIN_RELOADED, Constants::GIN_ROUTE, Constants::GIN_STACK, Constants::GIN_STATIC, Constants::GIN_TARGET, Constants::GIN_TEMPLATES, Constants::GIN_TIMESTAMP, Constants::HOST_NAME, Constants::HTTP_VERSION, Constants::IF_MATCH, Constants::IF_MOD_SINCE, Constants::IF_NONE_MATCH, Constants::IF_UNMOD_SINCE, Constants::LAST_MOD, Constants::LOCATION, Constants::PATH_INFO, Constants::PRAGMA, Constants::QUERY_STRING, Constants::RACK_INPUT, Constants::REMOTE_ADDR, Constants::REMOTE_USER, Constants::REQ_METHOD, Constants::SERVER_NAME, Constants::SERVER_PORT, Constants::SESSION_SECRET

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



7
8
9
# File 'lib/gin/response.rb', line 7

def body
  @body
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/gin/response.rb', line 6

def status
  @status
end

Instance Method Details

#finishObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/gin/response.rb', line 17

def finish
  body_out = body
  body_out = [body_out] if String === body_out
  header[CNT_TYPE] ||= 'text/html;charset=UTF-8'

  if NO_HEADER_STATUSES.include?(status.to_i)
    header.delete CNT_TYPE
    header.delete CNT_LENGTH

    if status.to_i > 200
      close
      body_out = []
    end
  end

  update_content_length

  [status.to_i, header, body_out]
end