code: def parse_request(cls, sock):
      
  
      command = None
      working_dir = None
      arguments = []
      environment = {}
  
      while not all((working_dir, command)):
        chunk_type, payload = cls.read_chunk(sock)
  
        if chunk_type == ChunkType.ARGUMENT:
          arguments.append(payload)
        elif chunk_type == ChunkType.ENVIRONMENT:
          key, val = payload.split(cls.ENVIRON_SEP, 1)
          environment[key] = val
        elif chunk_type == ChunkType.WORKING_DIR:
          working_dir = payload
        elif chunk_type == ChunkType.COMMAND:
          command = payload
        else:
          raise cls.ProtocolError('received non-request chunk before header was fully received!')
  
      return working_dir, command, arguments, environment
docs: Parse the request (the pre-execution) section of the nailgun protocol from the given socket.
  
      Handles reading of the Argument, Environment, Working Directory and Command chunks from the
      client which represents the "request" phase of the exchange. Working Directory and Command are
      required and must be sent as the last two chunks in this phase. Argument and Environment chunks
      are optional and can be sent more than once (thus we aggregate them).