applyContentHeaders.php
Table of Contents
Functions
- applyContentHeaders() : ResponseInterface
- Applies the download content headers (`Content-Type`, `Content-Length`, `Content-Disposition`) to a PSR-7 response, toggled by {@see FileResponseOption}.
Functions
applyContentHeaders()
Applies the download content headers (`Content-Type`, `Content-Length`, `Content-Disposition`) to a PSR-7 response, toggled by {@see FileResponseOption}.
applyContentHeaders(ResponseInterface $response, string $file[, string|null $contentType = null ][, array<string|int, mixed> $options = [] ][, bool $defaultOn = true ]) : ResponseInterface
Shared by the file/archive/image/encryption response helpers so the header logic lives in one place.
Parameters
- $response : ResponseInterface
-
The PSR-7 response to decorate.
- $file : string
-
Path of the file whose size/MIME type back the headers (must exist).
- $contentType : string|null = null
-
The
Content-Typeto advertise; when null,mime_content_type($file)is used. - $options : array<string|int, mixed> = []
-
Header switches keyed by FileResponseOption:
useContentType(bool) emitContent-Type.useContentLength(bool) emitContent-Length(file size).useContentDisposition(bool) emitContent-Disposition.contentDisposition(string) value to use (defaults toattachment; filename=<basename>).
- $defaultOn : bool = true
-
Default state of the three switches when absent from
$options.
Tags
Return values
ResponseInterface —The response with the requested headers applied.