Net::HTTPHeader Confusion

It appears Net::HTTPHeader conforms to the old cookie spec
( and not the current one
( with regards to multiple
Set-Cookie header value folding.

The problem is explained in this SO question:

require ‘net/http’

class Header
include Net::HTTPHeader

def initialize(header = {})

h =
h.add_field(‘Set-Cookie’, ‘name=cookie1;’)
h.add_field(‘Set-Cookie’, ‘name=cookie2;’)
puts h[‘Set-Cookie’]

This code outputs “name=cookie1;, name=cookie2;” which is the old way of
folding two set-cookie header values into one. The current solution is
to send a Set-Cookie header for each cookie value you want set.