24 lines
604 B
PHP
24 lines
604 B
PHP
<?php
|
|
// StreamContentHandler.php
|
|
// Created: 2024-03-28
|
|
// Updated: 2024-03-28
|
|
|
|
namespace Index\Http\ContentHandling;
|
|
|
|
use Index\Http\HttpResponseBuilder;
|
|
use Index\Http\Content\StreamContent;
|
|
use Index\IO\Stream;
|
|
|
|
class StreamContentHandler implements IContentHandler {
|
|
public function match(mixed $content): bool {
|
|
return $content instanceof Stream;
|
|
}
|
|
|
|
public function handle(HttpResponseBuilder $response, mixed $content): void {
|
|
if(!$response->hasContentType())
|
|
$response->setTypeStream();
|
|
|
|
$response->setContent(new StreamContent($content));
|
|
}
|
|
}
|