docs: def get_endpoint_and_path(environ):
      """Extracts "endpoint" and "path" from the request URL.
  
      Endpoint is the first path component, and path is the rest. Both
      of them are without leading slashes.
      """
      path = environ['PATH_INFO']
      components = path.split('/')
  
      if '..' in components:
          raise HttpError('400 Bad Request', 'Path cannot contain "..".')
  
      # Strip closing slash
      if components and components[-1] == '':
          components.pop()
  
      # If path contained '//', get the segment after the last occurence
      try:
          first = _rindex(components, '') + 1
      except ValueError:
          first = 0
  
      components = components[first:]
  
      if len(components) == 0:
          return '', ''
      else:
          return components[0], '/'.join(components[1:])