aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom Liou <artyomliou@gmail.com>2021-04-29 23:26:46 +0800
committerIrvin <irvinfly@gmail.com>2021-05-01 17:22:20 +0800
commit959085b62d7f0a9fc58de74c5df696dc8ec5491d (patch)
treed3f4f7a0d37dc5a0e77ac8c02cdabdbc9fd76134
parentf54f14458c6097c49a571d620620c8e3180c068d (diff)
downloadtranslated-content-959085b62d7f0a9fc58de74c5df696dc8ec5491d.tar.gz
translated-content-959085b62d7f0a9fc58de74c5df696dc8ec5491d.tar.bz2
translated-content-959085b62d7f0a9fc58de74c5df696dc8ec5491d.zip
web/http/headers/content-type (zh-TW translation)
-rw-r--r--files/zh-tw/web/http/headers/content-type/index.html121
1 files changed, 121 insertions, 0 deletions
diff --git a/files/zh-tw/web/http/headers/content-type/index.html b/files/zh-tw/web/http/headers/content-type/index.html
new file mode 100644
index 0000000000..a10fd0d34b
--- /dev/null
+++ b/files/zh-tw/web/http/headers/content-type/index.html
@@ -0,0 +1,121 @@
+---
+title: Content-Type
+slug: Web/HTTP/Headers/Content-Type
+tags:
+ - Content-Type
+ - Entity header
+ - HTTP
+ - Reference
+ - header
+---
+<div>{{HTTPSidebar}}</div>
+
+<p><strong><code>Content-Type</code></strong> 用來表示資源的 {{Glossary("MIME type","media type")}} 。</p>
+
+<p>在 HTTP 回應中,<code>Content-Type</code> 表頭是用來表示本次 HTTP 事務回傳的內容類型。瀏覽器有時會自己推測內容類型(MIME sniffing),如果要阻止這個行為,請在回應中設定 {{HTTPHeader("X-Content-Type-Options")}} 標頭為 <code>nosniff</code>。</p>
+
+<p>在 HTTP 請求中(比如 {{HTTPMethod("POST")}} 或 {{HTTPMethod("PUT")}}),則是客戶端用來告訴伺服器自己傳的資料是什麼內容類型。</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>
+ <tr>
+ <th scope="row">{{Glossary("CORS-safelisted response header")}}</th>
+ <td>yes</td>
+ </tr>
+ <tr>
+ <th scope="row">{{Glossary("CORS-safelisted request header")}}</th>
+ <td>yes, with the additional restriction that values can't contain a <em>CORS-unsafe request header byte</em>: 0x00-0x1F (except 0x09 (HT)), <code>"():&lt;&gt;?@[\]{}</code>, and 0x7F (DEL).<br>
+ It also needs to have a MIME type of its parsed value (ignoring parameters) of either <code>application/x-www-form-urlencoded</code>, <code>multipart/form-data</code>, or <code>text/plain</code>.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Syntax">語法</h2>
+
+<pre class="brush: html">Content-Type: text/html; charset=UTF-8
+Content-Type: multipart/form-data; boundary=something
+</pre>
+
+<h2 id="Directives">指令</h2>
+
+<dl>
+ <dt><code>media-type</code></dt>
+ <dd>資料的 <a href="/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types">內容類型(MIME type)</a></dd>
+ <dt>charset</dt>
+ <dd>編碼標準。</dd>
+ <dt>boundary</dt>
+ <dd>對於多段的資料必須要使用 <code>boundary</code> 指令,由 1 到 70 字的字元組成(這樣做很適合寄信),而且不能以空白結束。它會用來標誌資料的每一個段落。通常第一個段落的前面會加上兩個破折號(-),而最後一個段落後面也會加上兩個破折號。</dd>
+</dl>
+
+<h2 id="Examples">範例</h2>
+
+<h3 id="Content-Type_in_HTML_forms">在 HTML 表單設定 <code>Content-Type</code></h3>
+
+<p>你可以在 HTML {{HTMLElement("form")}} 的 <code>enctype</code> 屬性,設定表單送出後的 {{HTTPMethod("POST")}} 請求的 <code>Content-Type</code> 。</p>
+
+<pre class="brush: html">&lt;form action="/" method="post" enctype="multipart/form-data"&gt;
+ &lt;input type="text" name="description" value="some text"&gt;
+ &lt;input type="file" name="myFile"&gt;
+ &lt;button type="submit"&gt;Submit&lt;/button&gt;
+&lt;/form&gt;
+</pre>
+
+<p>HTTP 請求大概長這樣(省略了一些不重要的標頭):</p>
+
+<pre>POST /foo HTTP/1.1
+Content-Length: 68137
+Content-Type: multipart/form-data; boundary=---------------------------974767299852498929531610575
+
+-----------------------------974767299852498929531610575
+Content-Disposition: form-data; name="description"
+
+some text
+-----------------------------974767299852498929531610575
+Content-Disposition: form-data; name="myFile"; filename="foo.txt"
+Content-Type: text/plain
+
+(content of the uploaded file foo.txt)
+-----------------------------974767299852498929531610575--
+</pre>
+
+<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("7233", "Content-Type in multipart", "4.1")}}</td>
+ <td>Hypertext Transfer Protocol (HTTP/1.1): Range Requests</td>
+ </tr>
+ <tr>
+ <td>{{RFC("7231", "Content-Type", "3.1.1.5")}}</td>
+ <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{Compat("http.headers.Content-Type")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{HTTPHeader("Accept")}}</li>
+ <li>{{HTTPHeader("Content-Disposition")}}</li>
+ <li>{{HTTPStatus("206")}} Partial Content</li>
+ <li>{{HTTPHeader("X-Content-Type-Options")}}</li>
+</ul>