code: def _request(self, url, method='GET', params=None):
          
          self.connected = True
          retry_counter = 0
  
          method = method.lower()
          func = getattr(self.client, method)
          params, _ = _transparent_params(params)
  
          def _send(retry_counter):
              requests_args = {}
              for k, v in self.client_args.items():
                  # Maybe this should be set as a class
                  # variable and only done once?
                  if k in ('timeout', 'allow_redirects', 'verify'):
                      requests_args[k] = v
  
              while self.connected:
                  try:
                      if method == 'get':
                          requests_args['params'] = params
                      else:
                          requests_args['data'] = params
  
                      response = func(url, **requests_args)
                  except requests.exceptions.Timeout:
                      self.on_timeout()
                  else:
                      if response.status_code != 200:
                          self.on_error(response.status_code, response.content)
  
                      if self.retry_count and \
                         (self.retry_count - retry_counter) > 0:
                          time.sleep(self.retry_in)
                          retry_counter += 1
                          _send(retry_counter)
  
                      return response
  
          while self.connected:
              response = _send(retry_counter)
  
              for line in response.iter_lines(self.chunk_size):
                  if not self.connected:
                      break
                  if line:
                      try:
                          if is_py3:
                              line = line.decode('utf-8')
                          data = json.loads(line)
                      except ValueError:  # pragma: no cover
                          self.on_error(response.status_code,
                                        'Unable to decode response, \
                                        not valid JSON.')
                      else:
                          if self.on_success(data):  # pragma: no cover
                              for message_type in self.handlers:
                                  if message_type in data:
                                      handler = getattr(self,
                                                        'on_' + message_type,
                                                        None)
                                      if handler \
                                         and callable(handler) \
                                         and not handler(data.get(message_type)):
                                          break
  
          response.close()
docs: Internal stream request handling