jjlee / mechanize

Stateful programmatic web browsing in Python, after Andy Lester's Perl module WWW::Mechanize .
http://wwwsearch.sourceforge.net/mechanize/
618 stars 123 forks source link

Updating referer in case of URL redirection #103

Closed DheerendraRathor closed 6 years ago

DheerendraRathor commented 9 years ago

I found one nasty behavior in case of 302 URL redirects for example:

br = Browser()
res = br.open('http://fb.com') 

print res.geturl()
#This will print 'https://www.facebook.com/ (302 redirection)

req = br.request
print req.get_full_url()
#This will print 'http://fb.com'

Now if I submit any form or follow any URL on this page, the referer attached will be 'http://fb.com' as referer is taken from req.get_full_url() which is not desired behavior.