Internet - глобальная сеть передачи данных.www (World Wide Web) - множество взаимосвязанных документов, располагающихся на машинах подключенных к Internet.www - Набор протоколов и клиентского ПО, позволяющих получать доступ к документам.IP - глобальная адресация, передача в гетерогенной среде. Позволяет передавать пакеты по сети. Не гарантирует надёжную доставку.TCP - обеспечивает надёжную передачу данных. Если протокол ответил что пакет доставлен, значит он реально доставлен. Данные отправляются в потоке.DNS (Domain Name System) - система имён, позволяющая находить по имени хоста его IP адрес.HTTP, SSH, P2P, FTP - прикладные протоколы, решающие конкретные проблемы
FTP - протокол для загрузки и скачивания больших файловP2P - позволяет скачивать файлы с нескольких машин одновременно.SSH - позволяет с помощью шифрования получить доступ к другой машине.HTTP - расширенный протокол для передачи файлов, позволяет писать заголовки и т.д.content-type равен text/html.css, js, images, fonts) он начинает их загружать.html кода страницы браузер сразу начинает её отображать.URL - unified resouce locatorhttp - протоколserver.org - DNS имя сервера8080 - TCP порт/path/doc.html - путь к файлуa=1&b=2 - опции запросаpath1 - якорь, положение на страницеhttp://server.org/1.html - абсолютный URL//server.org/html - абсолютный URL (schemeless), выбор протокола будет осуществляться относительно страницы с которой запрашивается ресурс (если страница получена по http, то переход будет осуществляться по протоколу http, если основная по https то переход по https)/another/page.html?a=1 - относительный URL (за основу берется имя домена)pictures/1.png - относительно папки текущего документа?a=1&b=2 - этот же самый документ, полученный с другими параметрами#part2 - относительный (в пределах текущего документа)https://site.com/path/page.htmlhttp://wikipedia.org = http://wikipedia.org//cdn.org/jquery.js = https://cdn.org/jquery.js/admin/index.html = htpps://site.com/admin/index.htmlanother.html = https://site.com/path/another.html?full=1 = https://site.com/path/page.html?full=1#chapter2 = https://site.com/path/page.html#chapter2| GET | POST |
|---|---|
| Add parametrs to url | Do not add parametrs to url |
| Used for fetching data | Used for updating data |
| Affected by maximum url length | No maximum length |
| ok to cache | not ok to cache |
| should not change the server | it is ok to change the server |
REST - REpresentation State Transfer. An Architectural style for building APIs.
/users - get users list
/users/max - get max/users/max - updates max entity/user/ - create new user/users/max - delete user/ and without (for example /users/ and /users) should have the same handler. To implement such kind of behaviour we can use the following regex:/users/?Browser Limit
Good uses
To set cookie send header Set-Cookie from server:
Set-Cookie: user_id=12345`
If you want to set more than 1 cookie, just send multiple Set-Cookie header
Browser send cookies with cookies header:
cookie: user_id=12345;session_id=1238`
Cookie domain restriction:
Set-Cookie: user_id=12345; domain=www.site.com
Browser will only set cookie if server domain is the same or subdomain of domain in header (ends with that domain in cookie).
domain=foo.www.site.com - this works
domain=site.com - this doesn’t work
Browser will only send cookie to a server if server has the same domain as in cookie, or if server has top level domain
www.site.com - this works
.site.com - this works
By default Cookie is deleted when user closes the browser. To set expiration date use:
Set-Cookie: user_id=12345; Expires=Tue, 1 Jan 2025 00:00:0 GMT