From: Tobias Weber Date: 2008-06-07T17:04:01+09:00 Subject: Download using Safari's cookies Hi, the httpclient library includes a custom file-based cookie storage. I made a primitive drop-in replacement (myclient.cookie_manager = NSCookieManager.new) that uses OS X' built-in jar. It works for getting stuff from Safari, but new ones I save don't propagate back there. Probably to do with the AcceptPolicy. Anyway I thought I'd share it. The author's email is well hidden, so he probably doesn't like to be contacted. And I'm too lazy to create yet another Trac account. So see below. http://dev.ctor.org/http-access2/ require 'osx/cocoa' class NSCookieManager attr_accessor :cookies_file def initialize(file = nil) @cookies_file = file @jar = OSX::NSHTTPCookieStorage.sharedHTTPCookieStorage end def load_cookies end def save_cookies(force = nil) end def find(url) u = OSX::NSURL.URLWithString url.to_s a = @jar.cookiesForURL u d = OSX::NSHTTPCookie.requestHeaderFieldsWithCookies a return d["Cookie"] end def parse(str, url) u = OSX::NSURL.URLWithString url.to_s d = {"Set-Cookie" => str} a = OSX::NSHTTPCookie.cookiesWithResponseHeaderFields_forURL(d, u) @jar.setCookie a.shift raise unless a.empty? end end -- Tobias Weber