Sha256: cf86f33a2660b5c9a525afafeb778551253e0f1826b384b76c8c75231a8d3cab

Contents?: true

Size: 589 Bytes

Versions: 5

Compression:

Stored size: 589 Bytes

Contents

#
# A simple cookie jar thing
#
class UnderOs::HTTP::Cookies
  def initialize(cookies, url)
    @url  = url.is_a?(String) ? NSURL.URLWithString(url) : url
    @hash = cookies
  end

  def headers
    NSHTTPCookie.requestHeaderFieldsWithCookies(ios_cookies)
  end

  def to_s
    headers["Cookie"]
  end

protected

  def ios_cookies
    @hash.map do |key, value|
      NSHTTPCookie.cookieWithProperties({
        NSHTTPCookieDomain => @url.host,
        NSHTTPCookiePath   => "/",
        NSHTTPCookieName   => key.to_s,
        NSHTTPCookieValue  => value.to_s
      })
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
under-os-http-1.4.0 lib/under_os/http/cookies.rb
under-os-1.3.0 lib/under_os/http/cookies.rb
under-os-1.2.1 lib/under_os/http/cookies.rb
under-os-1.2.0 lib/under_os/http/cookies.rb
under-os-1.1.0 lib/under_os/http/cookies.rb