lib/rack/lint.rb in rack-1.5.5 vs lib/rack/lint.rb in rack-1.6.0.beta

- old
+ new

@@ -100,43 +100,84 @@ ## <tt>QUERY_STRING</tt>:: The portion of the request URL that ## follows the <tt>?</tt>, if any. May be ## empty, but is always required! - ## <tt>SERVER_NAME</tt>, <tt>SERVER_PORT</tt>:: When combined with <tt>SCRIPT_NAME</tt> and <tt>PATH_INFO</tt>, these variables can be used to complete the URL. Note, however, that <tt>HTTP_HOST</tt>, if present, should be used in preference to <tt>SERVER_NAME</tt> for reconstructing the request URL. <tt>SERVER_NAME</tt> and <tt>SERVER_PORT</tt> can never be empty strings, and so are always required. + ## <tt>SERVER_NAME</tt>, <tt>SERVER_PORT</tt>:: + ## When combined with <tt>SCRIPT_NAME</tt> and + ## <tt>PATH_INFO</tt>, these variables can be + ## used to complete the URL. Note, however, + ## that <tt>HTTP_HOST</tt>, if present, + ## should be used in preference to + ## <tt>SERVER_NAME</tt> for reconstructing + ## the request URL. + ## <tt>SERVER_NAME</tt> and <tt>SERVER_PORT</tt> + ## can never be empty strings, and so + ## are always required. ## <tt>HTTP_</tt> Variables:: Variables corresponding to the ## client-supplied HTTP request ## headers (i.e., variables whose ## names begin with <tt>HTTP_</tt>). The ## presence or absence of these ## variables should correspond with ## the presence or absence of the ## appropriate HTTP header in the - ## request. See <a href="https://tools.ietf.org/html/rfc3875#section-4.1.18"> - ## RFC3875 section 4.1.18</a> for specific behavior. + ## request. See + ## <a href="https://tools.ietf.org/html/rfc3875#section-4.1.18"> + ## RFC3875 section 4.1.18</a> for + ## specific behavior. ## In addition to this, the Rack environment must include these ## Rack-specific variables: - ## <tt>rack.version</tt>:: The Array representing this version of Rack. See Rack::VERSION, that corresponds to the version of this SPEC. - ## <tt>rack.url_scheme</tt>:: +http+ or +https+, depending on the request URL. + ## <tt>rack.version</tt>:: The Array representing this version of Rack + ## See Rack::VERSION, that corresponds to + ## the version of this SPEC. + + ## <tt>rack.url_scheme</tt>:: +http+ or +https+, depending on the + ## request URL. + ## <tt>rack.input</tt>:: See below, the input stream. + ## <tt>rack.errors</tt>:: See below, the error stream. - ## <tt>rack.multithread</tt>:: true if the application object may be simultaneously invoked by another thread in the same process, false otherwise. - ## <tt>rack.multiprocess</tt>:: true if an equivalent application object may be simultaneously invoked by another process, false otherwise. - ## <tt>rack.run_once</tt>:: true if the server expects (but does not guarantee!) that the application will only be invoked this one time during the life of its containing process. Normally, this will only be true for a server based on CGI (or something similar). - ## <tt>rack.hijack?</tt>:: present and true if the server supports connection hijacking. See below, hijacking. - ## <tt>rack.hijack</tt>:: an object responding to #call that must be called at least once before using rack.hijack_io. It is recommended #call return rack.hijack_io as well as setting it in env if necessary. - ## <tt>rack.hijack_io</tt>:: if rack.hijack? is true, and rack.hijack has received #call, this will contain an object resembling an IO. See hijacking. - ## + ## <tt>rack.multithread</tt>:: true if the application object may be + ## simultaneously invoked by another thread + ## in the same process, false otherwise. + + ## <tt>rack.multiprocess</tt>:: true if an equivalent application object + ## may be simultaneously invoked by another + ## process, false otherwise. + + ## <tt>rack.run_once</tt>:: true if the server expects + ## (but does not guarantee!) that the + ## application will only be invoked this one + ## time during the life of its containing + ## process. Normally, this will only be true + ## for a server based on CGI + ## (or something similar). + + ## <tt>rack.hijack?</tt>:: present and true if the server supports + ## connection hijacking. See below, hijacking. + + ## <tt>rack.hijack</tt>:: an object responding to #call that must be + ## called at least once before using + ## rack.hijack_io. + ## It is recommended #call return rack.hijack_io + ## as well as setting it in env if necessary. + + ## <tt>rack.hijack_io</tt>:: if rack.hijack? is true, and rack.hijack + ## has received #call, this will contain + ## an object resembling an IO. See hijacking. + ## Additional environment specifications have approved to ## standardized middleware APIs. None of these are required to ## be implemented by the server. - ## <tt>rack.session</tt>:: A hash like interface for storing request session data. + ## <tt>rack.session</tt>:: A hash like interface for storing + ## request session data. ## The store must implement: if session = env['rack.session'] ## store(key, value) (aliased as []=); assert("session #{session.inspect} must respond to store and []=") { session.respond_to?(:store) && session.respond_to?(:[]=) @@ -216,11 +257,10 @@ assert("env variable #{key} has non-string value #{value.inspect}") { value.kind_of? String } } - ## ## There are the following restrictions: ## * <tt>rack.version</tt> must be an array of Integers. assert("rack.version must be an Array, was #{env["rack.version"].class}") { env["rack.version"].kind_of? Array @@ -309,19 +349,27 @@ v.nil? or v.kind_of? String } v end - ## * +read+ behaves like IO#read. Its signature is <tt>read([length, [buffer]])</tt>. - ## If given, +length+ must be a non-negative Integer (>= 0) or +nil+, and +buffer+ must - ## be a String and may not be nil. If +length+ is given and not nil, then this method - ## reads at most +length+ bytes from the input stream. If +length+ is not given or nil, - ## then this method reads all data until EOF. - ## When EOF is reached, this method returns nil if +length+ is given and not nil, or "" - ## if +length+ is not given or is nil. - ## If +buffer+ is given, then the read data will be placed into +buffer+ instead of a - ## newly created String object. + ## * +read+ behaves like IO#read. + ## Its signature is <tt>read([length, [buffer]])</tt>. + ## + ## If given, +length+ must be a non-negative Integer (>= 0) or +nil+, + ## and +buffer+ must be a String and may not be nil. + ## + ## If +length+ is given and not nil, then this method reads at most + ## +length+ bytes from the input stream. + ## + ## If +length+ is not given or nil, then this method reads + ## all data until EOF. + ## + ## When EOF is reached, this method returns nil if +length+ is given + ## and not nil, or "" if +length+ is not given or is nil. + ## + ## If +buffer+ is given, then the read data will be placed + ## into +buffer+ instead of a newly created String object. def read(*args) assert("rack.input#read called with too many arguments") { args.size <= 2 } if args.size >= 1 @@ -582,11 +630,11 @@ ## The values of the header must be Strings, assert("a header value must be a String, but the value of " + "'#{key}' is a #{value.class}") { value.kind_of? String } ## consisting of lines (for multiple header values, e.g. multiple - ## <tt>Set-Cookie</tt> values) seperated by "\n". + ## <tt>Set-Cookie</tt> values) separated by "\\n". value.split("\n").each { |item| ## The lines must not contain characters below 037. assert("invalid header value #{key}: #{item.inspect}") { item !~ /[\000-\037]/ } @@ -658,10 +706,10 @@ ## The Body itself should not be an instance of String, as this will ## break in Ruby 1.9. ## ## If the Body responds to +close+, it will be called after iteration. If ## the body is replaced by a middleware after action, the original body - ## must be closed first, if it repsonds to close. + ## must be closed first, if it responds to close. # XXX howto: assert("Body has not been closed") { @closed } ## ## If the Body responds to +to_path+, it must return a String