%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/varak.net/nextcloud.varak.net/apps_old/apps/app_api/lib/
Upload File :
Create Path :
Current File : //www/varak.net/nextcloud.varak.net/apps_old/apps/app_api/lib/ProxyResponse.php

<?php

declare(strict_types=1);

namespace OCA\AppAPI;

use OCP\AppFramework\Http as HttpAlias;
use OCP\AppFramework\Http\ICallbackResponse;
use OCP\AppFramework\Http\IOutput;
use OCP\AppFramework\Http\Response;

/** @template-extends Response<int, array<string, mixed>> */
class ProxyResponse extends Response implements ICallbackResponse {
	private mixed $data;

	public function __construct(int $status = HttpAlias::STATUS_OK,
		array $headers = [], mixed $data = null, int $lastModified = 0) {
		parent::__construct();
		$this->data = $data;
		$this->setStatus($status);
		$this->setHeaders(array_merge($this->getHeaders(), $headers));
		if ($lastModified !== 0) {
			$lastModifiedDate = new \DateTime();
			$lastModifiedDate->setTimestamp($lastModified);
			$this->setLastModified($lastModifiedDate);
		}
	}

	public function callback(IOutput $output): void {
		if ($output->getHttpResponseCode() !== HttpAlias::STATUS_NOT_MODIFIED) {
			if (is_resource($this->data)) {
				fpassthru($this->data);
			} else {
				print $this->data;
			}
		}
	}
}

Zerion Mini Shell 1.0