Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to_cookie_string mutates CookieHash values #459

Closed
sethwoodworth opened this issue Jan 29, 2016 · 2 comments
Closed

to_cookie_string mutates CookieHash values #459

sethwoodworth opened this issue Jan 29, 2016 · 2 comments

Comments

@sethwoodworth
Copy link

delete_if { |k, v| CLIENT_COOKIES.include?(k.to_s.downcase) }.collect { |k, v| "#{k}=#{v}" }.join("; ")

[20] pry(main)> h
=> {:session=>"91e25e8b-6e32-418d-c72f-2d18adf041cd", :"Max-Age"=>"15552000", :cart=>"91e25e8b-6e32-418d-c72f-2d18adf041cd", :httponly=>nil, :Path=>"/", :secure=>nil}
[21] pry(main)> h.to_cookie_string
=> "session=91e25e8b-6e32-418d-c72f-2d18adf041cd; Max-Age=15552000; cart=91e25e8b-6e32-418d-c72f-2d18adf041cd"
[22] pry(main)> h
=> {:session=>"91e25e8b-6e32-418d-c72f-2d18adf041cd", :"Max-Age"=>"15552000", :cart=>"91e25e8b-6e32-418d-c72f-2d18adf041cd"}

I would not have expected to_cookie_string to be removing keys from a CookieHash. I understand removing keys that are not in CLIENT_COOKIES in the output of the method, but not mutating the parent object.

@jnunemaker
Copy link
Owner

That is really odd. I'm open to a PR that fixes it. Thanks for filing.

@mikeastock
Copy link
Contributor

I think this has been resolved by #460

jeremyct0220 added a commit to jeremyct0220/httparty that referenced this issue Dec 28, 2021
Solves jnunemaker/httparty#459. Reject returns
a new hash instead of mutating.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants