code: def urlopen(url, session, referrer=None, max_content_bytes=None,
              timeout=ConnectionTimeoutSecs, raise_for_status=True,
              stream=False, data=None, useragent=UserAgent):
      
      out.debug(u'Open URL %s' % url)
      headers = {'User-Agent': useragent}
      if referrer:
          headers['Referer'] = referrer
      out.debug(u'Sending headers %s' % headers, level=3)
      out.debug(u'Sending cookies %s' % session.cookies)
      kwargs = {
          "headers": headers,
          "timeout": timeout,
      }
      if hasattr(requests, 'adapters'):
          # requests >= 1.0
          kwargs["stream"] = stream
      else:
          # requests << 1.0
          kwargs["prefetch"] = not stream
          kwargs["config"] = {"max_retries": MaxRetries}
      if data is None:
          func = session.get
      else:
          kwargs['data'] = data
          func = session.post
          out.debug(u'Sending POST data %s' % data, level=3)
      try:
          req = func(url, **kwargs)
          out.debug(u'Response cookies: %s' % req.cookies)
          check_content_size(url, req.headers, max_content_bytes)
          if raise_for_status:
              req.raise_for_status()
          return req
      except requests.exceptions.RequestException as err:
          msg = 'URL retrieval of %s failed: %s' % (url, err)
          raise IOError(msg)
docs: Open an URL and return the response object.