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

Cookies not being Merged w/ Custom Cookie Headers #446

Closed
forced-request opened this issue Oct 2, 2015 · 1 comment
Closed

Cookies not being Merged w/ Custom Cookie Headers #446

forced-request opened this issue Oct 2, 2015 · 1 comment

Comments

@forced-request
Copy link

Hello,

I'm writing a tool that leverages Mechanize (2.3 from RubyGems) with custom headers (such as authorization headers, cookies, etc). I discovered some issues when dealing with 302 redirects in certain circumstances that relate to the following.

When leveraging custom headers, cookies are not being set as received from the HTTP response.

Consider this working example:

require 'mechanize'

req = Mechanize.new.tap do |r|
  r.set_proxy("localhost", 8080)
end

req.get "http://localhost:3000"

This examples loads localhost, which is running a rails-app. Upon loading that page it receives a 302 redirection, which it performs while overwriting the initial Rails session cookie, as it should.

Consider the next example:

require 'mechanize'

req = Mechanize.new.tap do |r|
  r.set_proxy("localhost", 8080)
end

headers = { "cookie" => "test=true" }

req.get "http://localhost:3000", [], nil, headers

Upon receiving the 302 redirect, it performs it, but the Rails session cookie is not being set. We're seeing the test cookie.

Is this a bug, or am I simply taking the wrong approach? The gist is that I need to be able to specify custom HTTP headers, including cookies, but follow the set-cookie response header as defined in the RFC.

@flavorjones
Copy link
Member

I'm sorry about the length of time that has passed without a reply. In an attempt to clean up the backlog of Mechanize issues, we're closing tickets that have had no recent activity.

If you'd like to re-open an issue to discuss, we'd be very thankful. Have a great day!

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

2 participants