Add remote install feature, create endpoint.

@param array $headers
@param array $install

@return mixed $install
193377
public function remote_install( $headers, $install ) {
		$options['gitea_access_token'] = isset( static::$options['gitea_access_token'] ) ? static::$options['gitea_access_token'] : null;

		$base = $headers['base_uri'] . '/api/v1';

		$install['download_link'] = "{$base}/repos/{$install['github_updater_repo']}/archive/{$install['github_updater_branch']}.zip";

		/*
		 * Add/Save access token if present.
		 */
		if ( ! empty( $install['gitea_access_token'] ) ) {
			$install['options'][ $install['repo'] ]   = $install['gitea_access_token'];
			$install['options']['gitea_access_token'] = $install['gitea_access_token'];
		}

		$token = ! empty( $install['options']['gitea_access_token'] )
			? $install['options']['gitea_access_token']
			: $options['gitea_access_token'];

		if ( ! empty( $token ) ) {
			$install['download_link'] = add_query_arg( 'access_token', $token, $install['download_link'] );
		}

		if ( ! empty( static::$options['gitea_access_token'] ) ) {
			unset( $install['options']['gitea_access_token'] );
		}

		return $install;
	}
1166750
public function setHeaders(array $headers)
	{
		foreach ($headers as $key => $header) {
			$this->setHeader($key, $header);
		}

		return $this;
	}
328367
public function setVary($headers, $replace = TRUE) {

		$this->headers->set('Vary', $headers, $replace);
		return $this;

	}
1182217
public function setHeaders($headers)
    {
        if (!empty($this->headers)) {
            $this->headers = array_merge($this->headers, $headers);
        } else {
            $this->headers = $headers;
        }
        $this->headers = array_merge($this->headers, $headers);

        if ($this->client instanceof \swoole_http_client) {
            $this->client->setHeaders($this->headers);
        }
        return $this;
    }
1115370
public function headers(array $headers): HttpRequest
    {
        foreach ($headers as $name => $value) {
            $this->header($name, $value);
        }

        return $this;
    }
964756
public function addHeaders(array $headers = [])
    {
        $this->headers = [];
        if($headers != []) {
            foreach ($headers as $header) {
                $this->headers[] = $header;
            }
        }
        return $this;
    }
824224
public static function fromArray(array $headers)
    {
        $instance = new static();

        if (isset($headers["content-type"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_CONTENT_TYPE;
            $instance->contentType = $headers["content-type"];
            unset($headers["content-type"]);
        }

        if (isset($headers["content-encoding"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_CONTENT_ENCODING;
            $instance->contentEncoding = $headers["content-encoding"];
            unset($headers["content-encoding"]);
        }

        if (isset($headers["delivery-mode"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_DELIVERY_MODE;
            $instance->deliveryMode = $headers["delivery-mode"];
            unset($headers["delivery-mode"]);
        }

        if (isset($headers["priority"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_PRIORITY;
            $instance->priority = $headers["priority"];
            unset($headers["priority"]);
        }

        if (isset($headers["correlation-id"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_CORRELATION_ID;
            $instance->correlationId = $headers["correlation-id"];
            unset($headers["correlation-id"]);
        }

        if (isset($headers["reply-to"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_REPLY_TO;
            $instance->replyTo = $headers["reply-to"];
            unset($headers["reply-to"]);
        }

        if (isset($headers["expiration"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_EXPIRATION;
            $instance->expiration = $headers["expiration"];
            unset($headers["expiration"]);
        }

        if (isset($headers["message-id"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_MESSAGE_ID;
            $instance->messageId = $headers["message-id"];
            unset($headers["message-id"]);
        }

        if (isset($headers["timestamp"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_TIMESTAMP;
            $instance->timestamp = $headers["timestamp"];
            unset($headers["timestamp"]);
        }

        if (isset($headers["type"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_TYPE;
            $instance->typeHeader = $headers["type"];
            unset($headers["type"]);
        }

        if (isset($headers["user-id"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_USER_ID;
            $instance->userId = $headers["user-id"];
            unset($headers["user-id"]);
        }

        if (isset($headers["app-id"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_APP_ID;
            $instance->appId = $headers["app-id"];
            unset($headers["app-id"]);
        }

        if (isset($headers["cluster-id"])) {
            $instance->flags |= ContentHeaderFrame::FLAG_CLUSTER_ID;
            $instance->clusterId = $headers["cluster-id"];
            unset($headers["cluster-id"]);
        }

        if (!empty($headers)) {
            $instance->flags |= ContentHeaderFrame::FLAG_HEADERS;
            $instance->headers = $headers;
        }

        return $instance;
    }
617679
protected function addAuthHeader(&$headers) {
		$user = $this->account->getKey();
		$password = $this->account->getSecret();

		$headers['Authorization'] = 'Basic ' . base64_encode("$user:$password");
	}
542338
public function install_plugins() {

		$result = system(
			WP_PHP_BINARY
			. ' ' . escapeshellarg( dirname( dirname( __FILE__ ) ) . '/bin/install-plugins.php' )
			. ' ' . escapeshellarg( json_encode( $this->plugins ) )
			. ' ' . escapeshellarg( $this->locate_wp_tests_config() )
			. ' ' . (int) is_multisite()
			. ' ' . escapeshellarg( json_encode( $this->files ) )
			, $exit_code
		);

		if ( 0 !== $exit_code ) {
			echo( 'Remote plugin installation failed with exit code ' . $exit_code . PHP_EOL );
			exit( 1 );
		} elseif ( ! empty( $result ) ) {
			echo( PHP_EOL . 'Remote plugin installation produced unexpected output.' . PHP_EOL );
			exit( 1 );
		}

		// The caching functions may not be loaded yet.
		if ( function_exists( 'wp_cache_flush' ) ) {
			wp_cache_flush();
		}

		remove_action( 'all', array( $this, 'install_plugins' ) );
	}
205873
public function AddHeader($header_name, &$content, $subdir="includes")
    {
        if($subdir)
        {
            $subdir = trim($subdir, "\\/") . "/";
            
            if(!file_exists($this->output_path . $subdir))
                \Peg\Lib\Utilities\FileSystem::MakeDir(
                    $this->output_path . $subdir, 
                    0755, 
                    true
                );
        }
        
        $header = $this->output_path 
            . $subdir
            . $this->GetHeaderNamePHP($header_name)
        ;
        
        \Peg\Lib\Utilities\FileSystem::WriteFileIfDifferent($header, $content);
    }
485628
function installContentObjects( $objectNodes, $topNodeListNode, &$installParameters )
    {
        if ( isset( $installParameters['user_id'] ) )
            $userID = $installParameters['user_id'];
        else
            $userID = eZUser::currentUserID();

        $handlerType = $this->handlerType();
        $firstInstalledID = null;

        foreach( $objectNodes as $objectNode )
        {
            $realObjectNode = $this->getRealObjectNode( $objectNode );

            // Cycle until we reach an element where error has occured.
            // If action has been choosen, try install this item again, else skip it.
            if ( isset( $installParameters['error']['error_code'] ) &&
                 !$this->isErrorElement( $realObjectNode->getAttribute( 'remote_id' ), $installParameters ) )
            {
                continue;
            }

            //we are here, it means we'll try to install some object.
            if ( !$firstInstalledID )
            {
                $firstInstalledID = $realObjectNode->getAttribute( 'remote_id' );
            }

            $newObject = eZContentObject::unserialize( $this->Package, $realObjectNode, $installParameters, $userID, $handlerType );
            if ( !$newObject )
            {
                return false;
            }

            if ( is_object( $newObject ) )
            {
                eZContentObject::clearCache( $newObject->attribute( 'id' ) );
                unset( $newObject );
            }
            unset( $realObjectNode );

            if ( isset( $installParameters['error'] ) && count( $installParameters['error'] ) )
            {
                $installParameters['error'] = array();
            }
        }

        $this->installSuspendedNodeAssignment( $installParameters );
        $this->installSuspendedObjectRelations( $installParameters );

        // Call postUnserialize on all installed objects
        foreach( $objectNodes as $objectNode )
        {
            if ( $objectNode->localName == 'object' )
            {
                $remoteID = $objectNode->getAttribute( 'remote_id' );
            }
            else
            {
                $remoteID = substr( $objectNode->getAttribute( 'filename' ), 7, 32 );
            }

            // Begin from the object that we started from in the previous cycle
            if ( $firstInstalledID && $remoteID != $firstInstalledID )
            {
                continue;
            }
            else
            {
                $firstInstalledID = null;
            }

            $object = eZContentObject::fetchByRemoteID( $remoteID );
            if ( is_object( $object ) )
            {
                $object->postUnserialize( $this->Package );
                eZContentObject::clearCache( $object->attribute( 'id' ) );
            }
            unset( $object );
        }

        return true;
    }
190211
public function createRequestFromArray(array $headers): GenericRequest
    {
        $upperCaseHeaders = [];

        foreach ($headers as $header => $value) {
            $upperCaseHeader = mb_strtoupper(str_replace('-', '_', $header));

            if (0 !== mb_strpos($upperCaseHeader, 'HTTP_')) {
                $upperCaseHeader = 'HTTP_' . $upperCaseHeader;
            }

            if (!HeaderSecurity::isValid($value)) {
                $value = $this->filterHeader($value);
            }

            $upperCaseHeaders[$upperCaseHeader] = $value;
        }

        $message = ServerRequestFactory::fromGlobals($upperCaseHeaders);

        return $this->createRequestFromPsr7Message($message);
    }
894957
public function install()
    {
        $this->shareDependenciesFolder();

        return $this->runWithBeforeAfterEvents(function () {
            return $this->getBinary()->runForApplication('install', [], $this->getInstallationOptions('install'));
        });
    }
722983
public function headers( array $headers )
      : Request
   {

      $this->_defaultHeaders = array_merge( $this->_defaultHeaders, $headers );

      return $this;

   }
1176656
public function addHeaders(array $headers)
    {
        foreach ($headers as $name => $value) {
            if (is_numeric($name)) {
                $this->parseHeaderLine($value);
            } else {
                $this->addHeader($name, $value);
            }
        }
        return $this;
    }
1076825
function usePackage($package, $scopes = []) {
        foreach((array) $scopes as $scope) {
            Manager::package($package)
                ->deferredScope($scope);
        }
        $this->require[$package] = $package;
        
        return $this;
    }
267261
public function addHeaders(array $headers)
    {
        $headerCollection = $this->getHeaders();
        foreach ($headers as $name => $value) {
            $headerCollection->add($name, $value);
        }
        return $this;
    }