Method: Manticore::Cookie#domain
- Defined in:
-
lib/manticore/cookie.rb,
lib/manticore/cookie.rb
Returns domain attribute of the cookie.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/manticore/cookie.rb', line 20 class Cookie # @private # Create a Manticore::Cookie wrapper from a org.apache.http.cookie.Cookie def self.from_java() if .get_expiry_date expiry = Time.at(.get_expiry_date / 1000) end new( comment: .get_comment, comment_url: .getCommentURL, domain: .get_domain, expires: expiry, name: .get_name, path: .get_path, ports: .get_ports.to_a, value: .get_value, secure: .is_secure, persistent: .is_persistent, spec_version: .get_version, ) end def self.(value) opts = {name: nil, value: nil} value.split(";").each do |part| k, v = part.split("=", 2).map(&:strip) if opts[:name].nil? opts[:name] = k opts[:value] = v end case k.downcase when "domain", "path" opts[k.to_sym] = v when "secure" opts[:secure] = true end end Manticore::Cookie.new opts end attr_reader :comment, :comment_url, :domain, :expires, :name, :path, :ports, :value, :spec_version def initialize(args) @comment = args.fetch(:comment, nil) @comment_url = args.fetch(:comment_url, nil) @domain = args.fetch(:domain, nil) @expires = args.fetch(:expires, nil) @name = args.fetch(:name, nil) @path = args.fetch(:path, nil) @ports = args.fetch(:ports, nil) @value = args.fetch(:value, nil) @secure = args.fetch(:secure, nil) @persistent = args.fetch(:persistent, nil) @spec_version = args.fetch(:spec_version, nil) end # @param date [Time] Time to compare against # # @return [Boolean] Whether this cookie is expired at the comparison date def expired?(date = Time.now) @expiry_date > date end # Whether this is a HTTPS-only cookie # # @return [Boolean] def secure? @secure end # Whether this is a persistent (session-only) cookie # # @return [Boolean] def persistent? @persistent end # Whether this is a session-only cookie # # @return [Boolean] def session? !@persistent end end |