]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
httputil: primitve cookie support
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 13 Sep 2007 13:25:51 +0000 (13:25 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 13 Sep 2007 13:25:51 +0000 (13:25 +0000)
If a redirection sets a cookie, set the cookie in the redirected request

lib/rbot/core/utils/httputil.rb

index f1976b5e96787b9e7ff5862203d55caf8f68346c..3a267da121fc9328ef2898516252b6602ff142ce 100644 (file)
@@ -389,6 +389,11 @@ class HttpUtil
         when :post, :"net::http::post"
           new_opts[:method] = :get
         end
+        if resp['set-cookie']
+          debug "setting cookie #{resp['set-cookie']}"
+          new_opts[:headers] ||= Hash.new
+          new_opts[:headers]['Cookie'] = resp['set-cookie']
+        end
         debug "following the redirect to #{new_loc}"
         return get_response(new_loc, new_opts, &block)
       else