title: How to set Referer using python mechanize?
body: <p>I'm writing python program to logging into a website programmatically. Now I'm having problem with handling cookies. Below are my code:</p>
  
  <pre><code>import mechanize
  cj = mechanize.CookieJar()
  browser = mechanize.Browser()
  browser.set_cookiejar(cj)
  opener = mechanize.build_opener(*browser.handlers)
  </code></pre>
  
  <p>It gives me error like this:</p>
  
  <pre><code>Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-  packages/django/core/handlers/base.py", line 111, in get_response
  
  response = callback(request, *callback_args, **callback_kwargs)
  File "/home/test/testEnv/apps/arachni/views.py", line 983, in handle_request
  content = opener.open(req, data).read()
  File "build/bdist.linux-i686/egg/mechanize/_opener.py", line 188, in open
  req = meth(req)
  File "build/bdist.linux-i686/egg/mechanize/_http.py", line 316, in http_request
  self.rfp.read()
  File "build/bdist.linux-i686/egg/mechanize/_http.py", line 242, in read
  f = self._opener.open(req)
  File "build/bdist.linux-i686/egg/mechanize/_opener.py", line 204, in open
  response = meth(req, response)
  File "build/bdist.linux-i686/egg/mechanize/_urllib2_fork.py", line 457, in http_response
  'http', request, response, code, msg, hdrs)
  File "build/bdist.linux-i686/egg/mechanize/_opener.py", line 221, in error
  result = apply(self._call_chain, args)
  File "build/bdist.linux-i686/egg/mechanize/_urllib2_fork.py", line 332, in _call_chain
  result = func(*args)
  File "build/bdist.linux-i686/egg/mechanize/_urllib2_fork.py", line 571, in http_error_302
  return self.parent.open(new)
  File "build/bdist.linux-i686/egg/mechanize/_opener.py", line 188, in open
  req = meth(req)
  File "build/bdist.linux-i686/egg/mechanize/_mechanize.py", line 71, in http_request
  request = self.parent._add_referer_header(
  AttributeError: OpenerDirector instance has no attribute '_add_referer_header'
  </code></pre>
  
  <p>Seem like I'm not dealing with "referer" correctly. Any idea?</p>