Skip to content
docs.
WORKSPACE

Your documentation

Explore the project catalog
Localzet ServerАсинхронный PHP-сервер✓TriangleФреймворк и компонентыMIX IDИдентификация и интеграцииHack APIПубличные API хакатонаACNПроект и компонентыUserlay / UserNetПроект и компонентыAxiomПроект и компонентыМесседжинг через почтуПроект и компонентыLWT / JWT / JOSEПроект и компонентыФинансовая аналитика KimaiПроект и компонентыМультипарадигмальная БДПроект и компонентыZorin PlatformПроект и компонентыZorin TrustПроект и компонентыFloraScope / VegwatchПроект и компонентыaegis-qДокументация проектаaevumdbДокументация проектаauditДокументация проектаauto-invest-managerАвтотрейдерcaine-companionДокументация проектаcertbot-cloudflareДокументация проектаClusterLocalzet Server / ClustercmdveilДокументация проектаConsolePHP CLICronБиблиотеки Localzet Serverdata-connectorДокументация проектаdevice-controlDevice Controlenn-projectДокументация проектаEventsБиблиотеки Localzet ServerflowsintДокументация проектаforgeДокументация проектаHttpClientБиблиотеки Localzet ServerinterpreterСобственный языкinvariaДокументация проектаkeynotesДокументация проектаknotrouteKnotroutelaravel-personal-analyticsДокументация проектаlocalzet-osДокументация проектаmeridianДокументация проектаMQTTБиблиотеки Localzet Servernano-kernelСобственная ОСNoterДокументация проектаpersonal-analyticsДокументация проектаProxyБиблиотеки Localzet ServerPSRБиблиотеки Localzet ServerPSR-7Библиотеки Localzet Serverrschs-monitorДокументация проектаsemsealДокументация проектаshardsealДокументация проектаSocketIOБиблиотеки Localzet ServerSOCKS5Библиотеки Localzet Serverstandalone-analyticsДокументация проектаstatic-php-cliДокументация проектаStorageБиблиотеки Localzet ServersutureДокументация проектаtempoweaveДокументация проектаttsСинтез речиTunnelБиблиотеки Localzet Serverui-kitUI KitvesperДокументация проектаWebAnalyzerWebAnalyzerzorin-access-brokerДокументация проектаzorin-authority-brokerДокументация проектаzorin-authority-sdk-phpДокументация проектаzorin-authority-sdk-pythonДокументация проектаzorin-authority-sdk-tsДокументация проектаzorin-client-intelДокументация проектаzorin-device-core-aospДокументация проектаzorin-host-agentДокументация проектаzorin-native-labДокументация проектаzorin-nodeДокументация проектаzorin-opsДокументация проектаdonstu-python-sdkДокументация проектаfloortraceFloortraceserver-rsLocalzet Server / Cluster
Catalog
Documentation/Localzet Server

HTTP response

Response is mutable and is not an immutable PSR-7 response. Every with*() returns the same instance. Create a response per request; never share a mutable response between clients.

header()/withHeader() and withHeaders() mutate the map. getHeader() and withoutHeader() match names case-insensitively, but writes preserve supplied casing: avoid duplicate names with different casing. getHeaders() returns the map. Serialization strips CR/LF from names/values; do not treat that as permission to accept arbitrary user-controlled headers.

cookie($name, $value, $maxAge, $path, $domain, $secure, $httpOnly, $sameSite) appends Set-Cookie and encodes name/value. Time means Max-Age in seconds, not a Unix timestamp. Set appropriate Secure/HttpOnly/SameSite and scope for authentication cookies; the application owns CSRF protection.

withFile($path, $offset = 0, $length = 0) prepares metadata; the HTTP codec performs transmission, not (string)$response. Missing/unreadable files produce 404. Negative offsets/lengths are rejected. Resolve paths inside authorized storage after access checks, never by concatenating an unchecked URL.

withFileForRequest($request, $path) handles GET/HEAD, preconditions (412), validators (304) and a single byte range (416 if unsatisfiable). Multiple ranges fall back to a full response; multipart/byteranges is not generated. Successful ranges remain metadata for the codec. ETag uses mtime/size, not a content hash.

withCompressionForRequest($request, $minBytes = 1024, $level = -1) explicitly enables gzip and accounts for q-values, Range, no-transform, existing encoding/stream/file and actual size reduction. Assess length leaks before compressing secrets together with reflected input.

withChunkedTransfer() removes Content-Length and clears the body. Send headers once, then Chunk objects, ending with an empty Chunk; do not send another Response for each event. See the executable SSE recipe.

Source.