Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/protocol/http/headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ def flatten
# @attribute [Array] An array of `[key, value]` pairs.
attr :fields

# @returns [Array] The fields of the headers.
def to_a
@fields
end

# @returns [Boolean] Whether there are any trailers.
def trailer?
@tail != nil
Expand Down
14 changes: 14 additions & 0 deletions test/protocol/http/headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@
end
end

with "#to_a" do
it "should return the fields array" do
expect(headers.to_a).to be == fields
end

it "should return the same object as fields" do
expect(headers.to_a).to be_equal(headers.fields)
end

it "should return an array" do
expect(headers.to_a).to be_a(Array)
end
end

with "#to_h" do
it "should generate array values for duplicate keys" do
expect(headers.to_h["set-cookie"]).to be == ["hello=world", "foo=bar"]
Expand Down
Loading