From 74fd1ecab2b83e29abd9caf865772701191ec8ef Mon Sep 17 00:00:00 2001 From: Riddick Date: Tue, 22 Oct 2024 09:31:57 +0200 Subject: [PATCH] Create lastModified method and added server bag to kernel (#95) --- phar/core.min.phar | Bin 428636 -> 429337 bytes phar/core.phar | Bin 1684641 -> 1687625 bytes src/kernel/console/firehub.Kernel.php | 7 +++- src/kernel/console/firehub.Response.php | 5 +++ src/kernel/http/firehub.Kernel.php | 7 +++- src/kernel/http/firehub.Response.php | 42 +++++++++++++++++++++-- src/kernel/http/micro/firehub.Kernel.php | 11 ++++-- 7 files changed, 65 insertions(+), 7 deletions(-) diff --git a/phar/core.min.phar b/phar/core.min.phar index 283c00066a9953d4f1d68c981cfb1ad0c956aeba..53aef1760944be3709e337b837ec3711ede9ba18 100644 GIT binary patch delta 4203 zcmZuzd0dl68cvWPa)bcEAcPQ(KnURoHvz*_Q3bxAP}3Y8Om^Z68P=nS$5sLFKr84B0f`E+!DgjUw;{H-f+j zH=6+00YK*N+cf) zHuAye2tSd?SWd|V3Y;MNZl^G^8g&9M3!NderOv^uPCAX&qU0MZE zhqAKfWCX8qE1n<+7YUK2y95x}VB{q|s6``q6lv4SMcridY^jROoI&R5b3H1U_>I1{Vn9 z$SPf!M4(Fu3{D8+$;!tAh+O9ZvM)R!5J!{@Mc<~;XiNNLUT9M2h$2N6s7u5oMm?ew z0yCmSP-Ej#x+=8@NkSH)Sx*zB@pL5eHc#+JUl`D6hCQxrM1_-9QsrG+QG1C?F-(x=l(~8?G;^D`F-rEfCSHoY zGr+tWo71eHu9h@z8pSF;e?-h-P<+-G>M)Zekj)%P5*YR1 zm{klj6*`j0MyDhKBAbw;fNU+!RiD#j3%Pdrnji~5YgFrJ1wu8BmUyR8hHK?vffYL8 z2hG0dM-{q}L8I-Fx)UxadA>i$SNcP52mP~1C}sfkE>r6DaS38H8emCO zehPquLjn^(40)gBw13`roBqs*NK@g#bf~P?+MDk!zX%7Z2ZcyMJ zLbbgQ`}9ffIE*GGJ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z8~3CS>oGz#Pr%f<&<46kzO)U8QQzSi>9+aN?i}4ye_EVF67ZO! zVKaSQN)yfJF!o%oP#3zMj^tQ6RhBNPE?rtBv3FHuWvT76Dk`;QuDT`F7MjUyi`Uco zOy>*QPS^1d`s>oomfR^!e+zBG?D>=4WRWnxvQ%3&e_5%-K0Z^e$tf+(_NkH*})6PS1yX*OKv7aE)~C zGOq9ciZtgi$w^#q=0p3CC+2N1V#*=#TgK)bP+NylnW}7DEAEsCMC1V3o)nR?Ttur2pMqB4ot3+*m+F4l-HOp>)p^dM3 zrQEjn%ffx1tb6v)mKE-ddDEU%*~dA*wGOvcf3yi7e~^JaZ5Z@=uRo5l6I-tP`q7$4a4)0e?(mg)MY@zXb*Ult*ajA@`3&7T;k z){Mv!N5@mQ7j0ND`0a6BX3x10YbNF8v0dRcqO=FQIpX&tuTFN=b+%jgZ~gVL*Z8AX zSG=1jC+o4$%}pNd2LD;NL$7b*DYwh(zQ*X}t}QcN @@ -40,7 +43,9 @@ class Kernel extends BaseKernel { */ public function handle (BaseRequest $request):Response { - return new Response($request, 'Console Torch'); + return new Response( + Container::getInstance()->resolve(Server::class), $request, 'Console Torch' + ); } diff --git a/src/kernel/console/firehub.Response.php b/src/kernel/console/firehub.Response.php index 0d0dd7cad..1406bd558 100644 --- a/src/kernel/console/firehub.Response.php +++ b/src/kernel/console/firehub.Response.php @@ -15,6 +15,7 @@ namespace FireHub\Core\Kernel\Console; use FireHub\Core\Kernel\Response as BaseResponse; +use FireHub\Core\Kernel\Console\Server; /** * ### Console Response @@ -28,6 +29,9 @@ class Response extends BaseResponse { * ### Constructor * @since 1.0.0 * + * @param \FireHub\Core\Kernel\Console\Server $server

+ * Console Server and execution environment information. + *

* @param \FireHub\Core\Kernel\Console\Request $request

* Interact with the current console request being handled by your application. *

@@ -38,6 +42,7 @@ class Response extends BaseResponse { * @return void */ public function __construct ( + protected readonly Server $server, protected readonly Request $request, protected string $content = '' ) {} diff --git a/src/kernel/http/firehub.Kernel.php b/src/kernel/http/firehub.Kernel.php index ec7ba19ed..a71feb3e1 100644 --- a/src/kernel/http/firehub.Kernel.php +++ b/src/kernel/http/firehub.Kernel.php @@ -16,6 +16,7 @@ use FireHub\Core\Initializers\Kernel as BaseKernel; use FireHub\Core\Kernel\Request as BaseRequest; +use FireHub\Core\Components\DI\Container; /** * ### HTTP Kernel @@ -30,6 +31,8 @@ class Kernel extends BaseKernel { * * @since 1.0.0 * + * @uses \FireHub\Core\Components\DI\Container::resolve() To resolve binding from the container. + * @uses \FireHub\Core\Kernel\HTTP\Server As HTTP Server and execution environment information. * @uses \FireHub\Core\Kernel\HTTP\Response As return. * * @param \FireHub\Core\Kernel\HTTP\Request $request

@@ -40,7 +43,9 @@ class Kernel extends BaseKernel { */ public function handle (BaseRequest $request):Response { - return (new Response($request, 'HTTP Torch')); + return (new Response( + Container::getInstance()->resolve(Server::class), $request, 'HTTP Torch') + ); } diff --git a/src/kernel/http/firehub.Response.php b/src/kernel/http/firehub.Response.php index 50474e7bf..37ebcbf9c 100644 --- a/src/kernel/http/firehub.Response.php +++ b/src/kernel/http/firehub.Response.php @@ -17,15 +17,18 @@ use FireHub\Core\Kernel\Response as BaseResponse; use FireHub\Core\Support\Str; use FireHub\Core\Support\Collection\Type\Indexed; +use FireHub\Core\Support\Zwick\ { + DateTime, Timestamp +}; use FireHub\Core\Support\Enums\HTTP\ { CommonMimeType, ContentDisposition, ContentEncoding, SiteData, StatusCode, - Authentication\Scheme, Contracts\StatusCode as StatusCodeContract, CSP\Directive, CSP\Value + Authentication\Scheme, Contracts\StatusCode as StatusCodeContract, CSP\Value }; use FireHub\Core\Support\Enums\ { - Language, Hash\Algorithm, String\Encoding + Language, DateTime\Format\Predefined, Hash\Algorithm, String\Encoding }; use FireHub\Core\Support\LowLevel\ { - Hash, HTTP + File, Hash, HTTP }; /** @@ -42,6 +45,9 @@ class Response extends BaseResponse { * ### Constructor * @since 1.0.0 * + * @param \FireHub\Core\Kernel\HTTP\Server $server

+ * HTTP Server and execution environment information. + *

* @param \FireHub\Core\Kernel\HTTP\Request $request

* Interact with the current HTTP request being handled by your application. *

@@ -52,6 +58,7 @@ class Response extends BaseResponse { * @return void */ public function __construct ( + protected readonly Server $server, protected readonly Request $request, protected string $content = '' ) {} @@ -346,6 +353,35 @@ public function eTag (string $value):self { } + /** + * ### Identifier for a specific version of a resource + * + * It lets caches be more efficient and save bandwidth, as a web server doesn't need to resend a full response if + * the content wasn't changed. Additionally, e-tags help to prevent simultaneous updates of a resource from + * overwriting each other ("midair collisions"). + * @since 1.0.0 + * + * @uses \FireHub\Core\Kernel\HTTP\Response::replaceHeader() To send and replace a raw HTTP header. + * @uses \FireHub\Core\Support\Zwick\DateTime::fromTimestamp() To create datetime from a script modified time. + * @uses \FireHub\Core\Support\Zwick\DateTime::parse() To parse date according to the given format. + * @uses \FireHub\Core\Support\Zwick\Timestamp::from() To create a timestamp from a script modified time. + * @uses \FireHub\Core\Support\LowLevel\File::lastModified() To get the last modification time of a script. + * @uses \FireHub\Core\Kernel\HTTP\Server::scriptFilename() To get the absolute pathname of the currently executing + * script. + * @uses \FireHub\Core\Support\Enums\DateTime\Format\Predefined::RFC7231 As datetime format. + * + * @return $this This response. + */ + public function lastModified ():self { + + $this->replaceHeader('Last-Modified: '.DateTime::fromTimestamp( + Timestamp::from(File::lastModified($this->server->scriptFilename())) + )->parse(Predefined::RFC7231)); + + return $this; + + } + /** * ### Send a raw HTTP header * @since 1.0.0 diff --git a/src/kernel/http/micro/firehub.Kernel.php b/src/kernel/http/micro/firehub.Kernel.php index aeca0b8a7..5897dbfa1 100644 --- a/src/kernel/http/micro/firehub.Kernel.php +++ b/src/kernel/http/micro/firehub.Kernel.php @@ -18,7 +18,10 @@ use FireHub\Core\Kernel\ { Request as BaseRequest, Response as BaseResponse }; -use FireHub\Core\Kernel\HTTP\Response; +use FireHub\Core\Kernel\HTTP\ { + Response, Server +}; +use FireHub\Core\Components\DI\Container; /** * ### Micro HTTP Kernel @@ -33,6 +36,8 @@ class Kernel extends BaseKernel { * * @since 1.0.0 * + * @uses \FireHub\Core\Components\DI\Container::resolve() To resolve binding from the container. + * @uses \FireHub\Core\Kernel\HTTP\Server As HTTP Server and execution environment information. * @uses \FireHub\Core\Kernel\HTTP\Response As return. * * @param \FireHub\Core\Kernel\HTTP\Request $request

@@ -43,7 +48,9 @@ class Kernel extends BaseKernel { */ public function handle (BaseRequest $request):BaseResponse { - return new Response($request, 'HTTP Micro Torch'); + return new Response( + Container::getInstance()->resolve(Server::class), $request, 'HTTP Micro Torch' + ); }