cookie: force name to string; as for the value, only late-force it on writing the cookie

This commit is contained in:
HoneyryderChuck 2021-07-15 15:09:09 +01:00
parent 00a6e4672d
commit 37f23ad8c3
2 changed files with 8 additions and 8 deletions

View File

@ -107,6 +107,8 @@ module HTTPX
@path ||= "/"
raise ArgumentError, "name must be specified" if @name.nil?
@name = @name.to_s
end
def expires
@ -122,7 +124,7 @@ module HTTPX
# Returns a string for use in the Cookie header, i.e. `name=value`
# or `name="value"`.
def cookie_value
"#{@name}=#{Scanner.quote(@value)}"
"#{@name}=#{Scanner.quote(@value.to_s)}"
end
alias_method :to_s, :cookie_value

View File

@ -31,19 +31,17 @@ module HTTPX
def valid_for_uri?: (uri) -> bool
def self.new: (Cookie) -> untyped
| (cookie_attributes) -> untyped
| (String, String) -> untyped
| (String, String, cookie_attributes) -> untyped
def self.new: (Cookie) -> instance
| (cookie_attributes) -> instance
| (_ToS, _ToS, ?cookie_attributes) -> instance
def self.path_match?: (String, String) -> bool
private
def initialize: (cookie_attributes) -> untyped
| (String, String) -> untyped
| (String, String, cookie_attributes?) -> untyped
| (_ToS, _ToS, ?cookie_attributes) -> untyped
def acceptable_from_uri?: (uri) -> bool
end
end