def _request(self, method, endpoint, include_session='cookies', **kwargs):
    """Make a request to Azkaban using this session.

    :param method: HTTP method.
    :param endpoint: Server endpoint (e.g. manager).
    :param include_session: Where to include the `session_id` (possible values:
      `'cookies'`, `'params'`, `False`).
    :param kwargs: Keyword arguments passed to :func:`_azkaban_request`.

    If the session expired, will prompt for a password to refresh.

    """
    full_url = '%s/%s' % (self.url, endpoint.lstrip('/'))

    if not self.id:
      self._logger.debug('No ID found.')
      self._refresh()

    def _send_request():
      """Try sending the request with the appropriate credentials."""
      if include_session == 'cookies':
        kwargs.setdefault('cookies', {})['azkaban.browser.session.id'] = self.id
      elif include_session == 'params':
        kwargs.setdefault('data', {})['session.id'] = self.id
      elif include_session:
        raise ValueError('Invalid `include_session`: %r' % (include_session, ))
      return _azkaban_request(method, full_url, verify=self.verify, **kwargs)

    response = _send_request()
    if not self.is_valid(response):
      self._refresh()
      response = _send_request()

    # `_refresh` raises an exception rather than letting an unauthorized second
    # request happen. this means that something is wrong with the server.
    if not self.is_valid(response):
      raise AzkabanError('Azkaban server is unavailable.')

    try:
      response.raise_for_status() # check that we get a 2XX response back
    except HTTPError as err: # catch, log, and reraise
      self._logger.warning(
        'Received invalid response from %s:\n%s',
        response.request.url, response.content
      )
      raise err
    else:
      return response
dataset/ETHPy150Open mtth/azkaban/azkaban/remote.py/Session._request/original