aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/http/заголовки/content-encoding/index.html
blob: 0f54a68395d5fd10b77d977f130e3db06b6cd11b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
title: Content-Encoding
slug: Web/HTTP/Заголовки/Content-Encoding
tags:
  - Content-Encoding
  - HTTP
  - Headers
translation_of: Web/HTTP/Headers/Content-Encoding
---
<div>{{HTTPSidebar}}</div>

<p><strong><code>Content-Encoding</code></strong> - это сущность заголовка, используемая для сжатия медиа-типа. При наличии ее значение определяет кодировку, примененную к сущности <strong><code>body</code></strong>. Это позволяет клиенту информацию как декодировать <strong><code>body</code></strong>, чтобы получить медиа-тип ссылающийся на  заголовок <code><strong>Content-Type </strong></code></p>

<p>Рекомендация - сжимать данные насколько это возможно и следовательно использовать это поле, но некоторые типы данных, такие как изображения в формате jpeg, уже сжаты. Иногда, использование дополнительного сжатия не уменьшает размер пакета и даже может сделать загрузку дольше.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("Entity header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>no</td>
  </tr>
 </tbody>
</table>

<h2 id="Синтаксис">Синтаксис</h2>

<pre class="syntaxbox">Content-Encoding: gzip
Content-Encoding: compress
Content-Encoding: deflate
Content-Encoding: identity
Content-Encoding: br

// Multiple, in the order in which they were applied
Content-Encoding: gzip, identity
Content-Encoding: deflate, gzip
</pre>

<h2 id="Директивы">Директивы</h2>

<dl>
 <dt><code>gzip</code></dt>
 <dd>A format using the <a class="external" href="http://en.wikipedia.org/wiki/LZ77_and_LZ78#LZ77">Lempel-Ziv coding</a> (LZ77), with a 32-bit CRC. This is the original format of the UNIX <em>gzip</em> program. The HTTP/1.1 standard also recommends that the servers supporting this content-encoding should recognize <code>x-gzip</code> as an alias, for compatibility purposes.</dd>
 <dt><code>compress</code></dt>
 <dd>A format using the <a class="external" href="http://en.wikipedia.org/wiki/LZW">Lempel-Ziv-Welch</a> (LZW) algorithm. The value name was taken from the UNIX <em>compress</em> program, which implemented this algorithm. Like the compress program, which has disappeared from most UNIX distributions, this content-encoding is not used by many browsers today, partly because of a patent issue (it expired in 2003).</dd>
 <dt><code>deflate</code></dt>
 <dd>Using the <a class="external" href="http://en.wikipedia.org/wiki/Zlib">zlib</a> structure (defined in <a class="external" href="http://tools.ietf.org/html/rfc1950">RFC 1950</a>) with the <a class="external" href="http://en.wikipedia.org/wiki/DEFLATE"><em>deflate</em></a> compression algorithm (defined in <a class="external" href="http://tools.ietf.org/html/rfc1951">RFC 1951</a>).</dd>
 <dt><code>identity</code></dt>
 <dd>Indicates the identity function (i.e., no compression or modification). This token, except if explicitly specified, is always deemed acceptable.</dd>
 <dt><code>br</code></dt>
 <dd>A format using the <a href="https://en.wikipedia.org/wiki/Brotli">Brotli</a> algorithm.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<h3 id="Compressing_with_gzip">Compressing with gzip</h3>

<p>On the client side, you can advertise a list of compression schemes that will be sent along in an HTTP request. The {{HTTPHeader("Accept-Encoding")}} header is used for negotiating content encoding.</p>

<pre>Accept-Encoding: gzip, deflate</pre>

<p>The server responds with the scheme used, indicated by the <code>Content-Encoding</code> response header.</p>

<pre>Content-Encoding: gzip</pre>

<p>Note that the server is not obligated to use any compression method. Compression highly depends on server settings and used server modules.</p>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Title</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{RFC("7932", "Brotli Compressed Data Format")}}</td>
   <td>Brotli Compressed Data Format</td>
  </tr>
  <tr>
   <td>{{RFC("7231", "Content-Encoding", "3.1.2.2")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
  </tr>
  <tr>
   <td>{{RFC("2616", "Content-Encoding", "14.11")}}</td>
   <td>Content-Encoding</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>

<p>{{Compat("http.headers.Content-Encoding")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{HTTPHeader("Accept-Encoding")}}</li>
 <li>{{HTTPHeader("Transfer-Encoding")}}</li>
</ul>