Project

General

Profile

Actions

Bug #4964

closed

open-uri failed to handle multiple "Set-Cookie" headers

Added by tdsparrow (ren li) over 12 years ago. Updated almost 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2p174 (2011-01-28 revision 30696) [i686-linux]
Backport:
[ruby-core:37734]

Description

=begin
== Problem
open-uri handle multiple "Set-Cookie" headers in a wrong way. Given a header from http server like:

   Set-Cookie: name1=value1; blabla
   Set-Cookie: name2=value2; blabla

open-uri will pack it into meta info of result like:

   Set-Cookie: name1=value; blabla, name2=value2; blabla

The problem is that line 332 of open-uri.rb
resp.each {|name,value| buf.io.meta_add_field name, value }

In turn will call invoke code in net/http.rb to join headers with ",".

== ruby -v:
ruby 1.9.2p174 (2011-01-28 revision 30696) [i686-linux]

== code:
require 'open-uri'
begin
open "http://douban.fm", :redirect => false
rescue OpenURI::HTTPRedirect => redirect
redirect.io.meta['set-cookie']
end

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0