diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2022-04-10 17:04:05 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-09 22:04:05 -0700 |
commit | 2c41211f640bfd1f6b8cb8a3973ff0769f93f8be (patch) | |
tree | b537d0342ebc84da36526a4195815ec36c85265c | |
parent | 56fe8ae3d187513aca3ba4bd905bdca2dba42d01 (diff) | |
download | rack-2c41211f640bfd1f6b8cb8a3973ff0769f93f8be.tar.gz |
Rework Rack::Response#initialize documentation to be RDoc format. (#1861)
-rw-r--r-- | lib/rack/response.rb | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/rack/response.rb b/lib/rack/response.rb index 55abb8d3..29524ff0 100644 --- a/lib/rack/response.rb +++ b/lib/rack/response.rb @@ -31,23 +31,33 @@ module Rack attr_accessor :length, :status, :body attr_reader :headers - # @deprecated Use {#headers} instead. + # Deprecated, use headers instead. def header warn 'Rack::Response#header is deprecated and will be removed in Rack 3.1', uplevel: 1 headers end - # Initialize the response object with the specified body, status - # and headers. + # Initialize the response object with the specified +body+, +status+ + # and +headers+. # - # @param body [nil, #each, #call, #to_str] the response body. - # @param status [Integer] the integer status as defined by the - # HTTP protocol RFCs. - # @param headers [Hash] a hash of key-value header pairs which - # conform to the HTTP protocol RFCs. + # If the +body+ is +nil+, construct an empty response object with internal + # buffering. + # + # If the +body+ responds to +to_str+, assume it's a string-like object and + # construct a buffered response object containing using that string as the + # initial contents of the buffer. # - # Providing a body which responds to #to_str is legacy behaviour. + # Otherwise it is expected +body+ conforms to the normal requiremnets of a + # Rack repsonse body, typically implementing one of +each+ (enumerable + # body) or +call+ (streaming body). + # + # The +status+ defaults to +200+ which is the "OK" HTTP status code. You + # can provide any other valid status code. + # + # The +headers+ must be a +Hash+ of key-value header pairs which conform to + # the Rack specification for response headers. The key must be a +String+ + # instance and the value can be either a +String+ or +Array+ instance. def initialize(body = nil, status = 200, headers = {}) @status = status.to_i |