nette-http
БесплатноБез исполняемых скриптовНе проверенInvoke before working with the HTTP layer in Nette – the request, the response, sessions or cookies. Covers Nette\Http\Request (getUrl/UrlScript, getPost…
от nette★ 47 звёзд на GitHubОб этом скилле
Nette Http
Installed with composer require nette/http. The framework registers http.request (Nette\Http\Request), http.response (Nette\Http\Response), http.requestFactory and session.session (Nette\Http\Session). All autowired – inject Nette\Http\IRequest / Nette\Http\IResponse / Nette\Http\Session by type; in presenters use $this->getHttpRequest(), $this->getHttpResponse(), $this->getSession() / $this->getSession('sectionName').
Request – read-only, already sanitized
Nette\Http\Request is immutable; RequestFactory::fromGlobals() strips control characters and invalid UTF-8 from GET/POST/COOKIE and the URL.
$url = $httpRequest->getUrl(); // UrlScript, not a string
$httpRequest->getQuery(); // all GET params; getQuery('id') for one (null if missing)
$httpRequest->getPost('name'); // POST param or null
$httpRequest->getCookie('lang'); // ?string; getCookies() for all
$httpRequest->getHeader('User-Agent'); // ?string, case-insensitive; getHeaders() keys are lowercase
$httpRequest->isSecured(); // HTTPS?
$httpRequest->isAjax(); // X-Requested-With: XMLHttpRequest
$httpRequest->getRemoteAddress(); // ?string
$httpRequest->getBasicCredentials(); // ?array – since 3.2 NOT in $url->getUser()/getPassword()
getRemoteAddress() and isSecured() are wrong behind a reverse proxy until you list the proxy, otherwise you get the load balancer's IP and http for a TLS-terminated request:
http:
proxy: 127.0.0.1 # IP, CIDR range, or a list of them
forceHttps: true # 3.3.4+; proxy does not send X-Forwarded-Proto at all
getReferer() and getRemoteHost() are deprecated (getRemoteHost() always returns null). Use getOrigin(): ?UrlImmutable – scheme+host+port from the Origin header, absent for plain navigation and same-origin GET.
File uploads – always index with getFile(), never walk the getFiles() tree, because the client controls its shape:
$file = $httpRequest->getFile(['my-form', 'details', 'avatar']); // ?FileUpload
if ($file?->hasFile()) {
$file->getUntrustedName(); // as sent by the user – never use as a path
$file->getSanitizedName(); // safe filename
$file->move($dest);
}
getFile() returns null when the field was submitted empty (UPLOAD_ERR_NO_FILE), so always
use ?->. It is the form control that hands you a dummy object instead: UploadControl
returns a FileUpload carrying that error unless setNullable() is on — that is where
hasFile() (did the user pick a file?) and isOk() (did it arrive intact?) differ.
Response – mutable, but only before output
Every setter throws Nette\InvalidStateException once headers are out; isSent() tells you. setHeader() replaces (and null deletes), addHeader() appends another line of the same name.
$httpResponse->setCode(IResponse::S404_NotFound);
$httpResponse->setExpiration('1 hour'); // Cache-Control + Expires; null = no cache at all
$httpResponse->sendAsFile('invoice.pdf');
$httpResponse->redirect($url); // does NOT terminate the script
In a presenter use $this->redirect() / $this->getHttpResponse()->redirect(); $this->terminate(); – Response::redirect() only sets Location and echoes a fallback link.
$httpResponse->setCookie('lang', 'en', '100 days'); // expiration: interval string, date, or null = session cookie
$httpResponse->setCookie('t', 'dark', '1 year', sameSite: SameSite::None, partitioned: true);
$httpResponse->deleteCookie('lang');
SameSite is now the enum Nette\Http\SameSite (Lax/Strict/None); the IResponse::SameSiteLax constants are deprecated. Defaults: sameSite = Lax, httpOnly = true, secure from http: cookieSecure (auto). SameSite=None and partitioned force Secure on regardless of what you pass. Passing an absolute UNIX timestamp as $expire is deprecated – a number means relative seconds; a session cookie is null, not 0.
Sessions
Never call session_start(), $_SESSION or session_regenerate_id() yourself – Nette configures the hardening ini directives (use_only_cookies, use_strict_mode, cookie_httponly, no trans-sid), namespaces data under $_SESSION['__NF'], and expires per-section/per-variable metadata at start. A hand-started session bypasses all of it.
The session starts lazily on the first read or write (autoStart: smart). Start it explicitly with $session->start() if you know you need it and output may already be flowing.
$section = $session->getSection('cart'); // SessionSection; $this->getSession('cart') in a presenter
$section->set('items', $items);
$section->set('flash', $msg, '30 seconds'); // 3rd arg = per-variable expiration
$section->get('items'); // null when missing
$section->remove('items'); // no argument = drop the whole section
$section->setExpiration('
Установить nette-http в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл nette-http?
Invoke before working with the HTTP layer in Nette – the request, the response, sessions or cookies. Covers Nette\Http\Request (getUrl/UrlScript, getPost, getQuery, getCookie, getFile/getFiles, getHeader, getOrigin, isFrom, isSecured, isAjax, getRemoteAddress and the proxy trap), Nette\Http\Response (setCookie and SameSite, setHeader vs addHeader, redirect, setExpiration, headers-before-output), sessions (Session, SessionSection, set/get/remove, per-key expiration, the `session:` NEON section, autoStart), the Sec-Fetch based CSRF / same-origin protection and how to allow a legitimate cross-origin POST, and the SSRF guards UrlValidator and IPAddress. Also trigger for file uploads (FileUpload), Url vs UrlImmutable vs UrlScript, getBasePath/getRelativeUrl, cookie flags, and the `http:` config section. Not for authentication or the `security:` section (see nette-security) nor for building forms (see nette-forms).
Как установить скилл nette-http?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nette-http запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic