Handle multivalued headers properly.
authorJames Bunton <jamesbunton@fastmail.fm>
Sun, 29 Jun 2008 16:10:34 +0000 (02:10 +1000)
committerJames Bunton <jamesbunton@fastmail.fm>
Sun, 29 Jun 2008 16:10:34 +0000 (02:10 +1000)
ruby/proxy.rb

index 6f98be7..21a92f4 100755 (executable)
@@ -74,13 +74,8 @@ def printResult(res)
        if res.code != "200"
                res["Status"] = "#{res.code} #{res.message}"
        end
-       res.each_capitalized do |key, value|
-               if key == "Set-Cookie"
-                       values = value.split(",")
-               else
-                       values = [value]
-               end
-               values.each do |value|
+       res.each_capitalized_name do |key|
+               res.get_fields(key).each do |value|
                        print "#{key}: #{value}\r\n"
                end
        end