File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,11 @@ def flatten
108108 # @attribute [Array] An array of `[key, value]` pairs.
109109 attr :fields
110110
111+ # @returns [Array] The fields of the headers.
112+ def to_a
113+ @fields
114+ end
115+
111116 # @returns [Boolean] Whether there are any trailers.
112117 def trailer?
113118 @tail != nil
Original file line number Diff line number Diff line change 11# Releases
22
3+ ## Unreleased
4+
5+ - Add ` Protocol::HTTP::Headers#to_a ` method that returns the fields array, providing compatibility with standard Ruby array conversion pattern.
6+
37## v0.51.0
48
59 - ` Protocol::HTTP::Headers ` now raise a ` DuplicateHeaderError ` when a duplicate singleton header (e.g. ` content-length ` ) is added.
Original file line number Diff line number Diff line change 148148 end
149149 end
150150
151+ with "#to_a" do
152+ it "should return the fields array" do
153+ expect ( headers . to_a ) . to be == fields
154+ end
155+
156+ it "should return the same object as fields" do
157+ expect ( headers . to_a ) . to be_equal ( headers . fields )
158+ end
159+
160+ it "should return an array" do
161+ expect ( headers . to_a ) . to be_a ( Array )
162+ end
163+ end
164+
151165 with "#to_h" do
152166 it "should generate array values for duplicate keys" do
153167 expect ( headers . to_h [ "set-cookie" ] ) . to be == [ "hello=world" , "foo=bar" ]
You can’t perform that action at this time.
0 commit comments