Revise SPEC to not require #each on header values (Ruby 1.9)
The SPEC currently requires response header values to respond to
The values of the header must respond to each. The values passed on each must be Strings and not contain characters below 037.
This needs to be revised so that Ruby 1.9 Strings are legal header values.
One solution is to simply change the SPEC to use "each_line" instead of "each":
The values of the header must respond to each_line. The values passed on each_line must be Strings and must not contain characters below 037.
This makes Strings valid header values.
This breaks cases where an Array was used for header values.
Code that used an Array for a header value should be modified to
join the Array with 012 (
Comments and changes to this ticket
One issue with this approach is that
String#each_linereturns the trailing line-end on each string it yields, which breaks the "must not contain characters below 037" constraint. Handlers and other multi-value consuming code will need to rstrip each value produced by
Here's a proposed implementation (top three commits):
The full suite of specs pass (i.e.,
Here's a summary of changes:
Rack::Linthas been updated to adjust the SPEC.
Arrayvalues for headers. Those values are converted to Strings with
join("\n")when converted to a true hash with
- All handlers have been modified to call
#eachon header values and to
rstripeach String value.
There's room for improvement here but I wanted to get a concrete proposal in place before starting a thread on the ML.
I put together another proposal based on the following SPEC text suggested by chris2:
The values of the header must be Strings, consisting of lines (for multiple header values) seperated by "\n". The lines must not contain characters below 037.
Branch is "headerspec2" in my rack repo:
commit be8f4ffdba31037082af28e3b984d6db72bdf927 Date: Sun Feb 1 00:57:22 2009 -0800 Handlers split header values on "\n" instead of using #each commit 826d080bc831222137cc1effef0eb0a69d9e367e Date: Sun Feb 1 00:48:58 2009 -0800 Normalize Array header values to Strings in HeaderHash#to_hash commit 96f8b7de1e3f5a714f1f2bf0694dd423108bcee6 Date: Sun Feb 1 00:17:36 2009 -0800 SPEC: header values must be Strings instead of responding to #each [#27]