Forum: Ruby-core [Ruby 1.9 - Bug #4964][Open] open-uri failed to handle multiple "Set-Cookie" headers

1cd39c62862b4dd8d914045f72ec46be?d=identicon&s=25 ren li (Guest)
on 2011-07-02 11:42
(Received via mailing list)
Issue #4964 has been reported by ren li.

----------------------------------------
Bug #4964: open-uri failed to handle multiple "Set-Cookie" headers
http://redmine.ruby-lang.org/issues/4964

Author: ren li
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.2p174 (2011-01-28 revision 30696) [i686-linux]


=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
C4e88907313843cf07f6d85ba8162120?d=identicon&s=25 Yui NARUSE (Guest)
on 2011-07-02 12:32
(Received via mailing list)
Issue #4964 has been updated by Yui NARUSE.

Category set to lib
Status changed from Open to Assigned
Assignee set to Akira Tanaka
Target version set to 1.9.3

See also http://tools.ietf.org/html/rfc6265
----------------------------------------
Bug #4964: open-uri failed to handle multiple "Set-Cookie" headers
http://redmine.ruby-lang.org/issues/4964

Author: ren li
Status: Assigned
Priority: Normal
Assignee: Akira Tanaka
Category: lib
Target version: 1.9.3
ruby -v: ruby 1.9.2p174 (2011-01-28 revision 30696) [i686-linux]


=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
6c06915d9aa00cd5c7d4acfb27cdd4e9?d=identicon&s=25 Hiroshi Nakamura (Guest)
on 2011-07-28 16:15
(Received via mailing list)
Issue #4964 has been updated by Hiroshi Nakamura.


As the original reporter said. Akr, we should use resp.to_hash instead
of resp.each to avoid HTTP header concatenation.

It would introduce meta values incompatibility (String -> Array of
String) so I propose to change the target version to '1.9.4'.
----------------------------------------
Bug #4964: open-uri failed to handle multiple "Set-Cookie" headers
http://redmine.ruby-lang.org/issues/4964

Author: ren li
Status: Assigned
Priority: Normal
Assignee: Akira Tanaka
Category: lib
Target version: 1.9.3
ruby -v: ruby 1.9.2p174 (2011-01-28 revision 30696) [i686-linux]


=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
B11f10c4cd9d53970e7be20caa43f940?d=identicon&s=25 Akira Tanaka (Guest)
on 2011-08-02 15:33
(Received via mailing list)
Issue #4964 has been updated by Akira Tanaka.

Target version changed from 1.9.3 to 1.9.x

I think we can fix the problem without incompatibility.
(new method to return array of field bodies for a field name.)

It needs new feature, though.

----------------------------------------
Bug #4964: open-uri failed to handle multiple "Set-Cookie" headers
http://redmine.ruby-lang.org/issues/4964

Author: ren li
Status: Assigned
Priority: Normal
Assignee: Akira Tanaka
Category: lib
Target version: 1.9.x
ruby -v: ruby 1.9.2p174 (2011-01-28 revision 30696) [i686-linux]


=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
7fe945668a4fc098e886e20dea71d2ee?d=identicon&s=25 zzak (Zachary Scott) (Guest)
on 2013-01-20 05:40
(Received via mailing list)
Issue #4964 has been updated by zzak (Zachary Scott).


This seems like feature, should move it to next minor or major?
----------------------------------------
Bug #4964: open-uri failed to handle multiple "Set-Cookie" headers
https://bugs.ruby-lang.org/issues/4964#change-35491

Author: tdsparrow (ren li)
Status: Assigned
Priority: Normal
Assignee: akr (Akira Tanaka)
Category: lib
Target version: 2.0.0
ruby -v: ruby 1.9.2p174 (2011-01-28 revision 30696) [i686-linux]


=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
9361878d459f1709feec780518946ee5?d=identicon&s=25 naruse (Yui NARUSE) (Guest)
on 2013-01-23 09:47
(Received via mailing list)
Issue #4964 has been updated by naruse (Yui NARUSE).

Target version changed from 2.0.0 to next minor


----------------------------------------
Bug #4964: open-uri failed to handle multiple "Set-Cookie" headers
https://bugs.ruby-lang.org/issues/4964#change-35543

Author: tdsparrow (ren li)
Status: Assigned
Priority: Normal
Assignee: akr (Akira Tanaka)
Category: lib
Target version: next minor
ruby -v: ruby 1.9.2p174 (2011-01-28 revision 30696) [i686-linux]


=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
This topic is locked and can not be replied to.