Core\Response
The response your program sends back to a request. sendHtml(), sendText(), sendJson(), sendBytes(), sendFile() and startStream() write the body, and each one sets the matching Content-Type. setStatus(), setHeader(), redirect() and addCookie() change the status line and the headers.
Members
11 members.
| Member | Signature |
|---|---|
sendHtml | sendHtml(Core\Html\Markup $body): void |
sendJson | sendJson(mixed $value): void |
sendText | sendText(string $body): void |
sendBytes | sendBytes(bytes $body, string $contentType): void |
sendFile | sendFile(string $path): void |
startStream | startStream(string $contentType, ?int $length = null, ?string $etag = null, ?string $mustEnd = null): Core\Response\Stream |
setStatus | setStatus(uint $code): void |
sendSlotted | sendSlotted(): void |
setHeader | setHeader(string $name, string $value): void |
redirect | redirect(string $url, Core\Response::Redirect $status = Core\Response::Redirect::SeeOther): void |
addCookie | addCookie(string $name, string $value, { secure?: bool, httpOnly?: bool, sameSite?: Core\Response::SameSite, path?: string, domain?: string, maxAge?: Core\Time\Duration }): void |
Enums
RedirectThe kind of redirect a response sends. Every browser handles these three statuses in the same way, so the browser does exactly what your program says.SameSiteWhich requests from other sites send a cookie. The three cases are the values of the cookie'sSameSiteattribute. The default isLax. A cookie that is sent with requests from other sites makes a CSRF attack possible.
Example apps
These complete apps use this class. You can download and run each one.
