Skip to content

Commit

Permalink
Create vary method (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
danijelgalic committed Oct 22, 2024
1 parent 1615e3b commit 998afc9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Binary file modified phar/core.min.phar
Binary file not shown.
Binary file modified phar/core.phar
Binary file not shown.
44 changes: 44 additions & 0 deletions src/kernel/http/firehub.Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,32 @@ public function cache (Indexed $directives):self {

}

/**
* ### Describes the parts of the request message aside from the method
*
* Describes the parts of the request message aside from the method and URL that influenced the content of the
* response it occurs in. Most often, this is used to create a cache key when content negotiation is in use.
* The same header value should be used on all responses for a given URL, including 304 Not Modified responses and
* the "default" response.
* @since 1.0.0
*
* @uses \FireHub\Core\Kernel\HTTP\Response::replaceHeader() To send and replace a raw HTTP header.
* @uses \FireHub\Core\Support\Str::fromList() To create a string from a list.
*
* @param \FireHub\Core\Support\Collection\Type\Indexed<non-empty-string> $headers <p>
* List of header names.
* </p>
*
* @return $this This response.
*/
public function vary (Indexed $headers):self {

$this->replaceHeader('Vary: '.Str::fromList($headers, ', '));

return $this;

}

/**
* ### Clears browsing data (cookies, storage, cache) associated with the requesting website
*
Expand Down Expand Up @@ -442,6 +468,8 @@ public function status (StatusCode $status_code):self {
* @since 1.0.0
*
* @uses \FireHub\Core\Kernel\HTTP\Response::replaceHeader() To send and replace a raw HTTP header.
* @uses \FireHub\Core\Support\Collection\Type\Associative::map() To apply the callback to each collection item.
* @uses \FireHub\Core\Support\Str::fromList() To create a string from a list.
*
* @param \FireHub\Core\Support\Collection\Type\Associative<non-empty-string, int|float> $metrics <p>
* List of metrics.
Expand All @@ -459,6 +487,22 @@ public function serverTiming (Associative $metrics):self {

}

/**
* ### Informs browsers that the site should only be accessed using HTTPS
* @since 1.0.0
*
* @uses \FireHub\Core\Kernel\HTTP\Response::replaceHeader() To send and replace a raw HTTP header.
*
* @return $this This response.
*/
public function forceHTTPS ():self {

$this->replaceHeader('Strict-Transport-Security: max-age=63072000; includeSubDomains; preload');

return $this;

}

/**
* ### Send a raw HTTP header
* @since 1.0.0
Expand Down

0 comments on commit 998afc9

Please sign in to comment.