开发者

Cookies in Mechanize 2.0

开发者 https://www.devze.com 2023-03-16 02:11 出处:网络
I’ve just upgraded and have a problem. Previously this code was working fine: page = ag.get(login_url)

I’ve just upgraded and have a problem. Previously this code was working fine:

page = ag.get(login_url)
form = page.forms.first
form.field_with(‘user[login]‘).value = login
form.field_with(‘user[password]‘).value = password

page = ag.submit(form)

It submits the login data to the Devise. In the log on server I see that user, auth token and password were submitted well. But I’m not getting logged in.

I also checked the mechanize logs and found a difference. For some unknown for me reason in new mechanize I don’t see this line:

DEBUG — : request-header: cookie => _vba.va.cc_session=…

This one is in both logs (2.0 and older one):

DEBUG — : response-header: set-cookie => _vba.va.cc_sess开发者_运维技巧ion=

Do you have any any solutions other then ‘gem mechanize, ‘< 2.0.0' ?

Thanks!


Ok, this is the bug. Mechanize resets cookies if you connect to the address without dots. For me that was http://rep:3000/ (I have a domain string in my resolv.conf). Also it looks like it will not work with IPv6 addresses.

0

精彩评论

暂无评论...
验证码 换一张
取 消