Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions lib/protocol/http/header/split.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ class Split < Array
#
# @parameter value [String | Nil] the raw header value containing multiple entries separated by commas, or `nil` for an empty header.
def initialize(value = nil)
if value
case value
when String
super(value.split(COMMA))
when nil
super()
else
super()
super([value.to_s])
end
end

Expand Down
8 changes: 5 additions & 3 deletions test/protocol/http/headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
["Set-Cookie", "hello=world"],
["Accept", "*/*"],
["set-cookie", "foo=bar"],
["connection", "Keep-Alive"]
["connection", "Keep-Alive"],
["X-Foo", 1]
]
end

Expand All @@ -29,7 +30,7 @@

with "#keys" do
it "should return keys" do
expect(headers.keys).to be == ["content-type", "set-cookie", "accept", "connection"]
expect(headers.keys).to be == ["content-type", "set-cookie", "accept", "connection", "x-foo"]
end
end

Expand All @@ -55,7 +56,8 @@
"content-type" => "text/plain",
"set-cookie" => ["hello=world", "foo=bar", "goodbye=world"],
"accept" => ["*/*"],
"connection" => ["keep-alive"]
"connection" => ["keep-alive"],
"x-foo" => ["1"]
}
end
end
Expand Down
Loading