From 980fe00a74a9ad013b945755415ace2e5429c3c2 Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Wed, 27 Oct 2021 02:31:24 +0300 Subject: [RU] Remove notranslate (#2874) --- files/ru/web/http/cors/index.html | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'files/ru/web/http/cors/index.html') diff --git a/files/ru/web/http/cors/index.html b/files/ru/web/http/cors/index.html index a4d1f6204f..b3392bc0e3 100644 --- a/files/ru/web/http/cors/index.html +++ b/files/ru/web/http/cors/index.html @@ -87,7 +87,7 @@ translation_of: Web/HTTP/CORS

Например, представьте, что содержимое домена http://foo.example хочет обратиться к содержимому http://bar.other. На домене foo.example может использоваться следующий Javascript код:

-
var invocation = new XMLHttpRequest();
+
var invocation = new XMLHttpRequest();
 var url = 'http://bar.other/resources/public-data/';
 
 function callOtherDomain() {
@@ -105,7 +105,7 @@ function callOtherDomain() {
 
 

Посмотрим, что браузер отправит в таком случае на сервер, а также проверим ответ сервера:

-
GET /resources/public-data/ HTTP/1.1
+
GET /resources/public-data/ HTTP/1.1
 Host: bar.other
 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20081130 Minefield/3.1b3pre
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
@@ -181,7 +181,7 @@ Content-Type: application/xml
 
 

Ниже приведён пример запроса, который будет предварительно просмотрен.

-
var invocation = new XMLHttpRequest();
+
var invocation = new XMLHttpRequest();
 var url = 'http://bar.other/resources/post-here/';
 var body = '<?xml version="1.0"?><person><name>Arun</name></person>';
 
@@ -209,7 +209,7 @@ function callOtherDomain(){
 
 

Давайте посмотрим на полный обмен между клиентом и сервером. Первый обмен - это предварительный запрос/ответ:

-
OPTIONS /resources/post-here/ HTTP/1.1
+
OPTIONS /resources/post-here/ HTTP/1.1
 Host: bar.other
 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20081130 Minefield/3.1b3pre
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
@@ -239,7 +239,7 @@ Content-Type: text/plain
 
 

Как только предварительный запрос завершён, отправляется настоящий запрос:

-
POST /resources/post-here/ HTTP/1.1
+
POST /resources/post-here/ HTTP/1.1
 Host: bar.other
 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20081130 Minefield/3.1b3pre
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
@@ -274,7 +274,7 @@ Content-Type: text/plain
 
 

Строки 1 - 12 выше представляют предварительный запрос с {{HTTPMethod("OPTIONS")}} методом. Браузер определяет, что ему нужно отправить это, основываясь на параметрах запроса, которые использовались во фрагменте кода JavaScript выше, чтобы сервер мог ответить, допустимо ли отправить запрос с фактическими параметрами запроса. OPTIONS - это метод HTTP/1.1, который используется для определения дополнительной информации от серверов, и является {{Glossary("safe")}} методом, что означает, что его нельзя использовать для изменения ресурса. Обратите внимание, что вместе с запросом OPTIONS отправляются два других заголовка запроса (строки 10 и 11 соответственно):

-
Access-Control-Request-Method: POST
+
Access-Control-Request-Method: POST
 Access-Control-Request-Headers: X-PINGOTHER, Content-Type
 
@@ -282,7 +282,7 @@ Access-Control-Request-Headers: X-PINGOTHER, Content-Type

Строки 14 - 26 выше - это ответ, который сервер отправляет обратно, указывая, что метод запроса (POST) и заголовки запроса (X-PINGOTHER) являются приемлемыми. В частности, давайте посмотрим на строки 17-20:

-
Access-Control-Allow-Origin: http://foo.example
+
Access-Control-Allow-Origin: http://foo.example
 Access-Control-Allow-Methods: POST, GET, OPTIONS
 Access-Control-Allow-Headers: X-PINGOTHER, Content-Type
 Access-Control-Max-Age: 86400
@@ -329,7 +329,7 @@ Access-Control-Max-Age: 86400

В этом примере контент, изначально загруженный из http://foo.example, выполняет простой GET запрос к ресурсу  http://bar.other, который устанавливает файлы cookie. Содержимое на foo.example может содержать такой JavaScript:

-
var invocation = new XMLHttpRequest();
+
var invocation = new XMLHttpRequest();
 var url = 'http://bar.other/resources/credentialed-content/';
 
 function callOtherDomain(){
@@ -347,7 +347,7 @@ function callOtherDomain(){
 
 

Вот пример обмена между клиентом и сервером:

-
GET /resources/access-control-with-credentials/ HTTP/1.1
+
GET /resources/access-control-with-credentials/ HTTP/1.1
 Host: bar.other
 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20081130 Minefield/3.1b3pre
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
@@ -398,14 +398,14 @@ Content-Type: text/plain
 
 

Возвращаемый ресурс может иметь один заголовок {{HTTPHeader("Access-Control-Allow-Origin")}}, синтаксис которого:

-
Access-Control-Allow-Origin: <origin> | *
+
Access-Control-Allow-Origin: <origin> | *
 

Access-Control-Allow-Origin определяет либо один источник, что указывает браузеру разрешить этому источнику доступ к ресурсу; либо — для запросов без учётных данных — значение "*", которое говорит браузеру разрешить запросы из любых источников.

Например, чтобы разрешить http://mozilla.org доступ к ресурсу, можно указать:

-
Access-Control-Allow-Origin: http://mozilla.org
+
Access-Control-Allow-Origin: http://mozilla.org

Если сервер возвращает название хоста, вместо "*", также может быть указан заголовок Vary со значением Origin, чтобы показать клиентам, что ответы с сервера будут отличаться в зависимости от значения заголовка запроса Origin.

@@ -413,7 +413,7 @@ Content-Type: text/plain

The {{HTTPHeader("Access-Control-Expose-Headers")}} header lets a server whitelist headers that browsers are allowed to access. For example:

-
Access-Control-Expose-Headers: X-My-Custom-Header, X-Another-Custom-Header
+
Access-Control-Expose-Headers: X-My-Custom-Header, X-Another-Custom-Header
 

This allows the X-My-Custom-Header and X-Another-Custom-Header headers to be exposed to the browser.

@@ -422,7 +422,7 @@ Content-Type: text/plain

The  {{HTTPHeader("Access-Control-Max-Age")}} header indicates how long the results of a preflight request can be cached. For an example of a preflight request, see the above examples.

-
Access-Control-Max-Age: <delta-seconds>
+
Access-Control-Max-Age: <delta-seconds>
 

The delta-seconds parameter indicates the number of seconds the results can be cached.

@@ -431,7 +431,7 @@ Content-Type: text/plain

The {{HTTPHeader("Access-Control-Allow-Credentials")}} header Indicates whether or not the response to the request can be exposed when the credentials flag is true.  When used as part of a response to a preflight request, this indicates whether or not the actual request can be made using credentials. Note that simple GET requests are not preflighted, and so if a request is made for a resource with credentials, if this header is not returned with the resource, the response is ignored by the browser and not returned to web content.

-
Access-Control-Allow-Credentials: true
+
Access-Control-Allow-Credentials: true
 

Credentialed requests are discussed above.

@@ -440,7 +440,7 @@ Content-Type: text/plain

The {{HTTPHeader("Access-Control-Allow-Methods")}} header specifies the method or methods allowed when accessing the resource. This is used in response to a preflight request. The conditions under which a request is preflighted are discussed above.

-
Access-Control-Allow-Methods: <method>[, <method>]*
+
Access-Control-Allow-Methods: <method>[, <method>]*
 

An example of a preflight request is given above, including an example which sends this header to the browser.

@@ -449,7 +449,7 @@ Content-Type: text/plain

The {{HTTPHeader("Access-Control-Allow-Headers")}} header is used in response to a preflight request to indicate which HTTP headers can be used when making the actual request.

-
Access-Control-Allow-Headers: <field-name>[, <field-name>]*
+
Access-Control-Allow-Headers: <field-name>[, <field-name>]*
 

The HTTP request headers

@@ -460,7 +460,7 @@ Content-Type: text/plain

The {{HTTPHeader("Origin")}} header indicates the origin of the cross-site access request or preflight request.

-
Origin: <origin>
+
Origin: <origin>
 

The origin is a URI indicating the server from which the request initiated.  It does not include any path information, but only the server name.

@@ -473,7 +473,7 @@ Content-Type: text/plain

The {{HTTPHeader("Access-Control-Request-Method")}} is used when issuing a preflight request to let the server know what HTTP method will be used when the actual request is made.

-
Access-Control-Request-Method: <method>
+
Access-Control-Request-Method: <method>
 

Examples of this usage can be found above.

@@ -482,7 +482,7 @@ Content-Type: text/plain

The {{HTTPHeader("Access-Control-Request-Headers")}} header is used when issuing a preflight request to let the server know what HTTP headers will be used when the actual request is made.

-
Access-Control-Request-Headers: <field-name>[, <field-name>]*
+
Access-Control-Request-Headers: <field-name>[, <field-name>]*
 

Examples of this usage can be found above.

-- cgit v1.2.3-54-g00ecf