From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- files/uk/web/http/session/index.html | 171 +++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 files/uk/web/http/session/index.html (limited to 'files/uk/web/http/session') diff --git a/files/uk/web/http/session/index.html b/files/uk/web/http/session/index.html new file mode 100644 index 0000000000..96e10d914a --- /dev/null +++ b/files/uk/web/http/session/index.html @@ -0,0 +1,171 @@ +--- +title: A typical HTTP session +slug: Web/HTTP/Session +translation_of: Web/HTTP/Session +--- +
{{HTTPSidebar}}
+ +

В клієнт-серверних протоколах таких як  HTTP, сесії складаються з трьох фаз:

+ +
    +
  1. Клієнт встановлює TCP з'єднання  (або підходяще з'єднання якщо неможливо зробити це на TCP).
  2. +
  3. Клієнт посилає запит , і очікує відповіді .
  4. +
  5. Сервер обробляє запит , І посилає відповідь , надаючи код статусу  і відповідні дані
  6. +
+ +

Починаючи з версії HTTP/1.1, з'єднання більше не  закривається після завершення третьої фази, і клієнту тепер надається можливість подальшого запиту: це означає, що друга та третя фази  можуть тепер виконуватись будь-яку кількість разів.

+ +

Встановлення з'єданння 

+ +

В клієнт-серверних протоколах , клієнт встановлює з'єднання. Відкриття з'єднання в HTTP Означає втановлення з'єднанняна транспортному рівні , зазвичай використовується TCP.

+ +

З TCP порт за замовчуванням, для HTTP сервера на будь-якому комп'ютері становить порт 80. Інші порти також можуть бути використані, як наприклад 8000 чи 8080. Для запиту сторінки URL повинен включати в себе домене ім'я та номер порту, але порт можна опустити якщо його номер 80. Дивись Identifying resources on the Web для детальної інформації.

+ +
Note: The client-server model does not allow the server to send data to the client without an explicit request for it. To work around this problem, web developers use several techniques: ping the server periodically via the {{domxref("XMLHTTPRequest")}}, {{domxref("Fetch")}} APIs, using the WebSockets API, or similar protocols.
+ +

Надсилання клієнтського запиту 

+ +

Once the connection is established, the user-agent can send the request (a user-agent is typically a web browser, but can be anything else, a crawler, for example). A client request consists of text directives, separated by CRLF (carriage return, followed by line feed), divided into three blocks:

+ +
    +
  1. The first line contains a request method followed by its parameters: +
      +
    • the path of the document, i.e. an absolute URL without the protocol or domain name
    • +
    • the HTTP protocol version
    • +
    +
  2. +
  3. Subsequent lines represent an HTTP header, giving the server information about what type of data is appropriate (e.g., what language, what MIME types), or other data altering its behavior (e.g., not sending an answer if it is already cached). These HTTP headers form a block which ends with an empty line.
  4. +
  5. The final block is an optional data block, which may contain further data mainly used by the POST method.
  6. +
+ +

Приклади запитів 

+ +

Fetching the root page of developer.mozilla.org, i.e. http://developer.mozilla.org/, and telling the server that the user-agent would prefer the page in French, if possible:

+ +
GET / HTTP/1.1
+Host: developer.mozilla.org
+Accept-Language: fr
+
+ +

Observe that final empty line, this separates the data block from the header block. As there is no Content-Length provided in an HTTP header, this data block is presented empty, marking the end of the headers, allowing the server to process the request the moment it receives this empty line.

+ +

For example, sending the result of a form:

+ +
POST /contact_form.php HTTP/1.1
+Host: developer.mozilla.org
+Content-Length: 64
+Content-Type: application/x-www-form-urlencoded
+
+name=Joe%20User&request=Send%20me%20one%20of%20your%20catalogue
+
+ +

Види методів 

+ +

HTTP defines a set of request methods indicating the desired action to be performed upon a resource. Although they can also be nouns, these requests methods are sometimes referred as HTTP verbs. The most common requests are GET and POST:

+ + + +

Структура  відповіді сервера 

+ +

After the connected agent has sent its request, the web server processes it, and ultimately returns a response. Similar to a client request, a server response is formed of text directives, separated by CRLF, though divided into three blocks:

+ +
    +
  1. The first line, the status line, consists of an acknowledgment of the HTTP version used, followed by a status request (and its brief meaning in human-readable text).
  2. +
  3. Subsequent lines represent specific HTTP headers, giving the client information about the data sent (e.g. type, data size, compression algorithm used, hints about caching). Similarly to the block of HTTP headers for a client request, these HTTP headers form a block ending with an empty line.
  4. +
  5. The final block is a data block, which contains the optional data.
  6. +
+ +

Приклади відповідей

+ +

Успішна відповідь :

+ +
HTTP/1.1 200 OK
+Content-Type: text/html; charset=utf-8
+Content-Length: 55743
+Connection: keep-alive
+Cache-Control: s-maxage=300, public, max-age=0
+Content-Language: en-US
+Date: Thu, 06 Dec 2018 17:37:18 GMT
+ETag: "2e77ad1dc6ab0b53a2996dfd4653c1c3"
+Server: meinheld/0.6.1
+Strict-Transport-Security: max-age=63072000
+X-Content-Type-Options: nosniff
+X-Frame-Options: DENY
+X-XSS-Protection: 1; mode=block
+Vary: Accept-Encoding,Cookie
+Age: 7
+
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="utf-8">
+  <title>A simple webpage</title>
+</head>
+<body>
+  <h1>Simple HTML5 webpage</h1>
+  <p>Hello, world!</p>
+</body>
+</html>
+
+ +

Notification that the requested resource has permanently moved:

+ +
HTTP/1.1 301 Moved Permanently
+Server: Apache/2.4.37 (Red Hat)
+Content-Type: text/html; charset=utf-8
+Date: Thu, 06 Dec 2018 17:33:08 GMT
+Location: https://developer.mozilla.org/ (this is the new link to the resource; it is expected that the user-agent will fetch it)
+Keep-Alive: timeout=15, max=98
+Accept-Ranges: bytes
+Via: Moz-Cache-zlb05
+Connection: Keep-Alive
+Content-Length: 325 (the content contains a default page to display if the user-agent is not able to follow the link)
+
+
+<!DOCTYPE html... (contains a site-customized page helping the user to find the missing resource)
+
+ +

Notification that the requested resource doesn't exist:

+ +
HTTP/1.1 404 Not Found
+Content-Type: text/html; charset=utf-8
+Content-Length: 38217
+Connection: keep-alive
+Cache-Control: no-cache, no-store, must-revalidate, max-age=0
+Content-Language: en-US
+Date: Thu, 06 Dec 2018 17:35:13 GMT
+Expires: Thu, 06 Dec 2018 17:35:13 GMT
+Server: meinheld/0.6.1
+Strict-Transport-Security: max-age=63072000
+X-Content-Type-Options: nosniff
+X-Frame-Options: DENY
+X-XSS-Protection: 1; mode=block
+Vary: Accept-Encoding,Cookie
+X-Cache: Error from cloudfront
+
+
+<!DOCTYPE html... (contains a site-customized page helping the user to find the missing resource)
+
+ +

Статус коди відповідей

+ +

HTTP response status codes indicate if a specific HTTP request has been successfully completed. Responses are grouped into five classes: informational responses, successful responses, redirects, client errors, and servers errors.

+ + + +

See also

+ + -- cgit v1.2.3-54-g00ecf