-
Notifications
You must be signed in to change notification settings - Fork 415
Response Headers don't overwrite cookies #217
Comments
I'd like to know you opinions here guys @jonleighton @yaauie it 'can overwrite cookies' do
@driver.set_cookie 'capybara', 'initial'
@session.visit('/set_cookie')
@session.visit('/get_cookie')
expect(@driver.body).to include('test_cookie')
end with this:
Let me explain what the hell is going on here :) For Safari:
For PhantomJS
Every single cookie I tried to set with PhantomJS API was prepended with a dot or rejected if there was something wrong with domain name. Considering this rfc http://tools.ietf.org/html/rfc2109#section-4.3.2 PhantomJS behavior is fishy. Further info about this concrete issue.
Thoughts? |
I agree that PhantomJS behaviour looks fishy, & I'm not sure of an immediate workaround on our end. Can you submit an issue over there & reference this one? |
I don't have thoughts about workaround either :( |
I've nothing in particular to add, I agree that this looks like a PhantomJS bug. |
Could be webkit related stuff :( http://qt.gitorious.org/qt/qt/source/764f1a51209212b6fc60cef5c12e9748d06b57de:src/network/access/qnetworkcookie.cpp#L1000 No it's not [EDITED] |
It appears I found the point causing this https://github.com/ariya/phantomjs/blob/master/src/qt/src/network/access/qnetworkcookiejar.cpp#L208 will try to open PR or issue and discuss the problem. |
Just wanted to leave a note here for anyone else trying to work around this problem - I was able to get the same functionality by setting a temporary cookie header manually. So to set a user id in a Rails signed session cookie: def sign_in_as(user)
session_key = Rails.configuration.session_options[:key]
cookie_jar = ActionDispatch::Cookies::CookieJar.new(Rails.configuration.secret_token)
cookie_jar.signed[session_key] = { value: { user_id: user.id } }
signed_cookie = [session_key, Rack::Utils.escape(cookie_jar[session_key])].join('=')
page.driver.add_header 'Cookie', signed_cookie, permanent: false
end |
Hi, stumbled up this as well. My solution was to add the cookie with javascript (using jquery-cookie in this case), which does not prepend the leading period:
|
page.driver.set_cookie("user_id", 1)
visit "/change_user?user_id=2"
page.response_headers["Set-Cookie"].match("user_id=2").should_not be_nil
page.driver.cookies["user_id"].value.should == 2
The text was updated successfully, but these errors were encountered: