Net::HTTPHeader Confusion

It appears Net::HTTPHeader conforms to the old cookie spec
(http://www.ietf.org/rfc/rfc2109.txt) and not the current one
(http://www.rfc-editor.org/rfc/rfc6265.txt) with regards to multiple
Set-Cookie header value folding.

The problem is explained in this SO question:
http://stackoverflow.com/questions/11533867/set-cookie-header-with-multiple-cookies.

Example:
require ‘net/http’

class Header
include Net::HTTPHeader

def initialize(header = {})
initialize_http_header(header)
end
end

h = Header.new
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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs