You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vrací origin, ze kterého požadavek přišel. Origin se skládá z protokolu, hostname a portu - například `https://example.com:8080`. Vrací `null`, pokud hlavička origin není přítomna nebo je nastavena na `'null'`.
190
+
191
+
```php
192
+
$origin = $httpRequest->getOrigin();
193
+
echo $origin; // https://example.com:8080
194
+
echo $origin?->getHost(); // example.com
195
+
```
196
+
197
+
Prohlížeč posílá hlavičku `Origin` v následujících případech:
198
+
- Požadavky mezi doménami (AJAX volání na jinou doménu)
199
+
- POST, PUT, DELETE a další modifikující požadavky
200
+
- Požadavky provedené pomocí Fetch API
201
+
202
+
Prohlížeč NEPOSÍLÁ hlavičku `Origin` při:
203
+
- Běžných GET požadavcích na stejnou doménu (navigace v rámci téže domény)
204
+
- Přímé navigaci zadáním URL do adresního řádku
205
+
- Požadavcích z jiných klientů než prohlížeče (pokud není ručně přidána)
206
+
207
+
.[note]
208
+
Na rozdíl od hlavičky `Referer` obsahuje `Origin` pouze schéma, host a port - nikoli celou cestu URL. To ji činí vhodnější pro bezpečnostní kontroly při zachování soukromí uživatele. Hlavička `Origin` se primárně používá pro validaci [CORS |nette:glossary#Cross-Origin Resource Sharing (CORS)] (Cross-Origin Resource Sharing).
209
+
210
+
187
211
detectLanguage(array $langs): ?string .[method]
188
212
-----------------------------------------------
189
213
Detekuje jazyk. Jako parametr `$lang` předáme pole s jazyky, které aplikace podporuje, a ona vrátí ten, který by viděl návštěvníkův prohlížeč nejraději. Nejsou to žádná kouzla, jen se využívá hlavičky `Accept-Language`. Pokud nedojde k žádné shodě, vrací `null`.
Vrací cestu k dočasné lokaci uploadovaného souboru. V případě, že upload nebyl úspěšný, vrací `''`.
390
414
391
415
416
+
__toString(): string .[method]
417
+
------------------------------
418
+
Vrací cestu k dočasnému umístění nahraného souboru. To umožňuje objekt `FileUpload` použít přímo jako řetězec.
419
+
420
+
392
421
isImage(): bool .[method]
393
422
-------------------------
394
423
Vrací `true`, pokud nahraný soubor je obrázek ve formátu JPEG, PNG, GIF, WebP nebo AVIF. Detekce probíhá na základě jeho signatury a neověřuje se integrita celého souboru. Zda není obrázek poškozený lze zjistit například pokusem o jeho [načtení |#toImage].
Převede URL do kanonického tvaru. To zahrnuje například seřazení parametrů v query stringu podle abecedy, převod hostname na malá písmena a odstranění nadbytečných znaků.
Returns the origin from which the request came. An origin consists of the scheme (protocol), hostname, and port - for example, `https://example.com:8080`. Returns `null` if the origin header is not present or is set to `'null'`.
190
+
191
+
```php
192
+
$origin = $httpRequest->getOrigin();
193
+
echo $origin; // https://example.com:8080
194
+
echo $origin?->getHost(); // example.com
195
+
```
196
+
197
+
The browser sends the `Origin` header in the following cases:
198
+
- Cross-origin requests (AJAX calls to a different domain)
199
+
- POST, PUT, DELETE, and other modifying requests
200
+
- Requests made using the Fetch API
201
+
202
+
The browser does NOT send the `Origin` header for:
203
+
- Regular GET requests to the same domain (same-origin navigation)
204
+
- Direct navigation by typing a URL into the address bar
205
+
- Requests from non-browser clients
206
+
207
+
.[note]
208
+
Unlike the `Referer` header, `Origin` contains only the scheme, host, and port - not the full URL path. This makes it more suitable for security checks while preserving user privacy. The `Origin` header is primarily used for [CORS |nette:glossary#Cross-Origin Resource Sharing (CORS)] (Cross-Origin Resource Sharing) validation.
209
+
210
+
187
211
detectLanguage(array $langs): ?string .[method]
188
212
-----------------------------------------------
189
213
Detects the language. Pass an array of languages supported by the application as the `$langs` parameter, and it will return the one preferred by the visitor's browser. It's not magic; it just uses the `Accept-Language` header. If no match is found, it returns `null`.
Returns the path to the temporary location of the uploaded file. If the upload was not successful, it returns `''`.
390
414
391
415
416
+
__toString(): string .[method]
417
+
------------------------------
418
+
Returns the path to the temporary location of the uploaded file. This allows the `FileUpload` object to be used directly as a string.
419
+
420
+
392
421
isImage(): bool .[method]
393
422
-------------------------
394
423
Returns `true` if the uploaded file is a JPEG, PNG, GIF, WebP, or AVIF image. Detection is based on its signature and does not verify the integrity of the entire file. Whether an image is corrupted can be determined, for example, by trying to [load it |#toImage].
Copy file name to clipboardExpand all lines: http/en/response.texy
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -34,9 +34,9 @@ isSent(): bool .[method]
34
34
Returns whether headers have already been sent from the server to the browser, meaning it is no longer possible to send headers or change the status code.
35
35
36
36
37
-
setHeader(string $name, string $value) .[method]
38
-
------------------------------------------------
39
-
Sends an HTTP header and **overwrites** a previously sent header of the same name.
37
+
setHeader(string $name, ?string $value) .[method]
38
+
-------------------------------------------------
39
+
Sends an HTTP header and **overwrites** a previously sent header of the same name. If `$value` is `null`, the header will be removed.
Converts the URL to canonical form. This includes, for example, sorting the parameters in the query string alphabetically, converting the hostname to lowercase, and removing redundant characters.
Nette Framework **automaticky chrání formuláře a signály v presenterech** před tímto typem útoku. A to tím, že zabraňuje jejich odeslání či vyvolání z jiné domény.
37
37
38
38
39
+
Cross-Origin Resource Sharing (CORS)
40
+
------------------------------------
41
+
CORS je bezpečnostní mechanismus, který umožňuje webové stránce provádět JavaScriptové požadavky na jinou doménu, než ze které byla stránka načtena. Bez CORS prohlížeče takové požadavky z bezpečnostních důvodů blokují.
42
+
43
+
Například pokud vaše webová stránka běží na `https://myapp.com` a pokusí se pomocí JavaScriptu (AJAX, Fetch API) načíst data z `https://api.example.com`, prohlížeč ověří, zda API server tento požadavek mezi doménami povoluje. API server musí odpovědět speciálními HTTP hlavičkami, jako je `Access-Control-Allow-Origin: https://myapp.com`, aby udělil povolení.
44
+
45
+
39
46
Dependency Injection
40
47
--------------------
41
48
Dependency Injection (DI) je návrhový vzor, který říká, jak oddělit vytváření objektů od jejich závislostí. Tedy že třída není zodpovědná za vytváření nebo inicializaci svých závislostí, ale místo toho jsou jí tyto závislosti poskytovány externím kódem (tím může i [DI kontejner |#Dependency Injection kontejner]). Výhoda spočívá v tom, že umožňuje větší flexibilitu kódu, lepší srozumitelnost a snazší testování aplikace, protože závislosti jsou snadno nahraditelné a izolované od ostatních částí kódu. Více v kapitole [Co je Dependency Injection? |dependency-injection:introduction]
Copy file name to clipboardExpand all lines: nette/en/glossary.texy
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,13 @@ A Cross-Site Request Forgery attack involves the attacker luring a victim to a p
36
36
Nette Framework **automatically protects forms and signals in presenters** against this type of attack by preventing them from being submitted or triggered from another domain.
37
37
38
38
39
+
Cross-Origin Resource Sharing (CORS)
40
+
------------------------------------
41
+
CORS is a security mechanism that allows a web page to make JavaScript requests to a different domain than the one from which the page was loaded. Without CORS, browsers block such requests for security reasons.
42
+
43
+
For example, if your website runs at `https://myapp.com` and tries to fetch data from `https://api.example.com` using JavaScript (AJAX, Fetch API), the browser will check if the API server allows this cross-origin request. The API server must respond with special HTTP headers, such as `Access-Control-Allow-Origin: https://myapp.com`, to grant permission.
44
+
45
+
39
46
Dependency Injection
40
47
--------------------
41
48
Dependency Injection (DI) is a design pattern that dictates how to separate the creation of objects from their dependencies. This means a class is not responsible for creating or initializing its dependencies; instead, these dependencies are provided by external code (which could be a [DI container |#Dependency Injection Container]). The advantage lies in increased code flexibility, better understandability, and easier application testing, as dependencies are easily replaceable and isolated from other code parts. More in the chapter [What is Dependency Injection? |dependency-injection:introduction]
0 commit comments