Sha256: 551c99d38c9c1c434f1da5c5284f7778d51acff324690ede9eaa21d09a3e0c44

Contents?: true

Size: 586 Bytes

Versions: 85

Compression:

Stored size: 586 Bytes

Contents

# frozen_string_literal: true

class HTTParty::CookieHash < Hash #:nodoc:
  CLIENT_COOKIES = %w(path expires domain path secure httponly samesite)

  def add_cookies(data)
    case data
    when Hash
      merge!(data)
    when String
      data.split('; ').each do |cookie|
        key, value = cookie.split('=', 2)
        self[key.to_sym] = value if key
      end
    else
      raise "add_cookies only takes a Hash or a String"
    end
  end

  def to_cookie_string
    select { |k, v| !CLIENT_COOKIES.include?(k.to_s.downcase) }.collect { |k, v| "#{k}=#{v}" }.join('; ')
  end
end

Version data entries

85 entries across 85 versions & 3 rubygems

Version Path
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.91 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.90 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.89 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.88 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.86 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.85 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.84 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.83 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.82 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/lib/httparty/cookie_hash.rb