def get_cookie_header(request_uri, opts = {})
      cookies = get_cookies request_uri, opts
      ver = [[], []]
      cookies.each do |cookie|
        ver[cookie.version] << cookie
      end
      if ver[1].empty?
        # can do a netscape-style cookie header, relish the opportunity
        cookies.map(&:to_s).join ';'
      else
        # build a RFC 2965-style cookie header. Split the cookies into
        # version 0 and 1 groups so that we can reuse the '$Version' header
        result = ''
        unless ver[0].empty?
          result << '$Version=0;'
          result << ver[0].map do |cookie|
            (cookie.to_s 1, false)
          end.join(';')
          # separate version 0 and 1 with a comma
          result << ','
        end
        result << '$Version=1;'
        ver[1].map do |cookie|
          result << (cookie.to_s 1, false)
        end
        result
      end
    end
def get_cookie_header(request_uri, opts = {})
      cookies = get_cookies request_uri, opts
      ver = [[], []]
      cookies.each do |cookie|
        ver[cookie.version] << cookie
      end
      if ver[1].empty?
        # can do a netscape-style cookie header, relish the opportunity
        cookies.map(&:to_s).join ';'
      else
        # build a RFC 2965-style cookie header. Split the cookies into
        # version 0 and 1 groups so that we can reuse the '$Version' header
        result = ''
        unless ver[0].empty?
          result << '$Version=0;'
          result << ver[0].map do |cookie|
            (cookie.to_s 1, false)
          end.join(';')
          # separate version 0 and 1 with a comma
          result << ','
        end
        result << '$Version=1;'
        ver[1].map do |cookie|
          result << (cookie.to_s 1, false)
        end
        result
      end
    end
Given a request URI, return a string Cookie header.Cookies will be in
 order per RFC 2965 - sorted by longest path length, but otherwise
 unordered.

 @param [String, URI] request_uri the address the HTTP request will be
   sent to
 @param [Hash] opts options controlling returned cookies
 @option opts [Boolean] :script (false) Cookies marked HTTP-only will be
   ignored if true
 @return String value of the Cookie header which should be sent on the
   HTTP request